Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Problems Transfering div contents x-browser

    Hello friends

    I have the follow html page (do you can copy and save as test.htm, by example)

    <div id="divOrigin">
    <STYLE> <!-- .Test1 { color: #0000FF; font-weight: bold } .Test2 { color: #FF0000; font-weight: bold } --> </STYLE>
    <span class='Test1'>Test1</span>
    <span class='Test2'>Test2</span>
    </div>
    <div id="divDestination"></div>

    <SCRIPT type="text/javascript">
    <!--

    function CopyContents(div1, div2)
    {
    div2.innerHTML = div1.innerHTML;
    }

    someDiv = document.getElementById("divOrigin");
    otherDiv = document.getElementById("divDestination");

    CopyContents(someDiv,otherDiv);

    alert(someDiv.innerHTML);
    alert(otherDiv.innerHTML);

    //-->
    </SCRIPT>


    Please, check the contents of divOrigin, and the 2 alertboxes in Internet Explorer and FireFox...

    IE (Alert1):
    <STYLE> <!-- .Test1 { color: #0000FF; font-weight: bold } .Test2 { color:
    #FF0000; font-weight: bold } --> </STYLE>
    <span class='Test1'>Test1</span>
    <span class='Test2'>Test2</span>


    IE (Alert2), FireFox(Alert1) and FireFox(Alert2):
    <span class='Test1'>Test1</span> <span class='Test2'>Test2</span>
    I wish one EXACT COPY of contents from divOrigin to divDestination, but I know not how I can do it works in Firefox and IE... I need what all alerts show equals of IE(Alert1).

    Someone can help me?

    Denize
    Last edited by denizedenez; 03-25-2005 at 03:46 AM.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    looks like a homework, and usually we don't do others' homeworks... Except maybe if you have already worked till a point where we can show you the error/nest step/debugging process.

    So, can u give us more details and what have you build so far?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Quote Originally Posted by Kor
    looks like a homework, and usually we don't do others' homeworks...
    Kor, sorry but I don't understood.... what one homework have with my code snippet?

    I think what I showed to you what I have tested very well the code (as in IE as in Firefox) and I showed the results in both browsers...

    Quote Originally Posted by Kor
    Except maybe if you have already worked till a point where we can show you the error/nest step/debugging process.
    Well, if your need of more details... In my website the 2 divs are in separated frames, then I need transfer the html in div1 to div2, but not works... I did this small, easy-to-understand sample reproducing the problem... But appears what you think what is one homework?
    Quote Originally Posted by Kor
    So, can u give us more details and what have you build so far?
    I have tryied this too:
    Code:
    function CopyContents(div1, div2)		
    {
       var content = div1.innerHTML;
       for (var i=0; i<content.length; i++)
       {
          var theChar = content.charAt(i);
          if (theChar == "<")
          {
             theChar += "\<";			    
          }
             div2.innerHTML += theChar;
          }		
    }
    But this not work too...

    I need this to one urgent project, and I know not what I can do... Javascript is too odd...

    Regards
    Denize

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I need transfer the html in div1 to div2,
    Ok now...
    1. Where should be the action (onclick, for instance). On parent?
    2. What you wanna copy? Text, html code?

    To reach the frames from another frame or from parent, you may try the reference

    top.frames['framename'].object
    top.frames['framename'].somefunction()
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Kor
    1. Where should be the action (onclick, for instance). On parent?
    My action is happening in onload. I have not problem with this, the function is called correctly
    Quote Originally Posted by Kor
    2. What you wanna copy? Text, html code?
    Here is the problem.. I wish transfer this HTML code:
    Code:
    <STYLE> <!-- .Test1 { color: #0000FF; font-weight: bold } .Test2 { color: #FF0000; font-weight: bold } --> </STYLE>
    <span class='Test1'>Test1</span>
    <span class='Test2'>Test2</span>
    Including the <Style> tag... but the <Style> is not tranfered...

    What I can do?

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is just my own explanation not sure its true.


    But styles are global, so nomatter where you define the style its applies to all elements fills the criteria for getting the style.

    <element class="t">
    <style>.t{}<style>

    So my presumption is that it is not considered any part of the inner of a html tag since it still applies to the out side of the tag in which it is written. And copying such a global tag to several parts of a document don't add anything ekstra.

    But then again I migth be wrong and its a bug .

  • #7
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb

    Quote Originally Posted by Garadon
    This is just my own explanation not sure its true.


    But styles are global, so nomatter where you define the style its applies to all elements fills the criteria for getting the style.

    <element class="t">
    <style>.t{}<style>

    So my presumption is that it is not considered any part of the inner of a html tag since it still applies to the out side of the tag in which it is written. And copying such a global tag to several parts of a document don't add anything ekstra.

    But then again I migth be wrong and its a bug .
    Perfect, Garadon, you are right.

    But I need this my code to transfer from one frame to another, i.e., from one page to another. I know what I can put all in one .css file and do one reference, but appears strange to me what both Firefox and IE we cannot perform this simple operation, of copy ALL div contents to another div, including style tags...

    Thank you very much


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •