Problem about creating DIV in parent window from child window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kingfly2000
    New Member
    • Jan 2010
    • 2

    #1

    Problem about creating DIV in parent window from child window

    I have a probelm about creating DIV in parent window from child window. following code works find in IE8, but it does not work in IE7 and 6

    aaa.html

    Code:
    <html>
    <head>
    <title>aaa</title>
    </head>
    <body>
    <iframe src=bbb.html height=0 width=0></iframe>
    </body>
    </html>
    bbb.html

    Code:
    <script type="text/javascript">
    var objdiv = document.createElement("DIV");
    objdiv.id = "testdiv";
    objdiv.innerHTML="bbb";
    parent.document.body.appendChild(objdiv);
    </script>
    Last edited by Dormilich; Jan 2 '10, 12:22 PM. Reason: Please use [code] tags when posting code
  • kingfly2000
    New Member
    • Jan 2010
    • 2

    #2
    no need to give solution, i have already found it in this forum, please check:


    solution is very simple, change

    var objdiv = document.create Element("DIV");

    to

    var objdiv = parent.document .createElement( "DIV");

    Comment

    Working...