Results 1 to 2 of 2

Thread: Probelm about creating DIV in parent window from child window

  1. #1
    kingfly2000 Guest

    Probelm 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

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

    <script type="text/javascript">
    var objdiv = document.createElement("DIV");
    objdiv.id = "testdiv";
    objdiv.innerHTML="bbb";
    parent.document.body.appendChild(objdiv);
    </script>

  2. #2
    Join Date
    Jan 2010
    Location
    Nanning,Guangxi,China
    Posts
    5
    appendChild() doesn't work in IE(6,7) with iframe's parent/child
    there's other ways:
    1. call a parent's function
    2. use innerHTML

    i.e.

    ---bbb.html---

    <script type="text/javascript">
    window.parent.document.body.innerHTML='<div id="testdiv">bbb</div>';
    </script>

Similar Threads

  1. Floating Child Divs height not inherited by Parent Div
    By neojohan in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 11 Sep 2009, 04:15 AM

Posting Permissions

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