By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,693 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,693 IT Pros & Developers. It's quick & easy.

Problem about creating DIV in parent window from child window

P: 2
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

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>aaa</title>
  4. </head>
  5. <body>
  6. <iframe src=bbb.html height=0 width=0></iframe>
  7. </body>
  8. </html>
bbb.html

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. var objdiv = document.createElement("DIV");
  3. objdiv.id = "testdiv";
  4. objdiv.innerHTML="bbb";
  5. parent.document.body.appendChild(objdiv);
  6. </script>
Jan 2 '10 #1
Share this Question
Share on Google+
1 Reply


P: 2
no need to give solution, i have already found it in this forum, please check:
http://bytes.com/topic/javascript/an...ild-method-ie6

solution is very simple, change

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

to

var objdiv = parent.document.createElement("DIV");
Jan 2 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.