471,831 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,831 software developers and data experts.

Append Child working in Mozilla but not in IE.

2,476 2GB
Have a look at my code fragment...

Expand|Select|Wrap|Line Numbers
  1. var parent_UL_ref = parent.document.getElementById(..);
  2. var child_LI_ref = document.createElement('LI');
  3. parent_UL_ref.appendChild(child_LI_ref); //it's not working
Actually my question is if create an element using document.createElement, can it be added into any another document. I think that's what happening here ... ;)
May 6 '09 #1
5 4550
247 Expert 100+
normally there shouldnt be a problem with it. i'm doing the same in my current project. only there i create divs containing dynamically created paragraphs.

another option:
Expand|Select|Wrap|Line Numbers
  1. var parent_UL_ref = parent.document.getElementById(..);
  2. var parent_UL_ref .style.innerHTML += "<li>item</li>
May 6 '09 #2
16,027 Expert Mod 8TB
You need to use imporNode.
May 6 '09 #3
2,476 2GB
Here you directly setting the innerHTML. I am talking about the document.createElement ;)
May 6 '09 #4
2,476 2GB
Well i got the solution...

I have a opener window and a pop-up window, and there code given below.

Expand|Select|Wrap|Line Numbers
  1. //onload function
  2. function openPopUp(){
  3.  window.open(......);
  4. }
Expand|Select|Wrap|Line Numbers
  1. //add-list handler
  2. function addList(){
  3.  var parent_UL_ref = opener.document.getElementById(..) ; //get the opener UL reference
  4.  var child_LI_ref = document.createElement('LI');
  5.  parent_UL_ref.appendChild(child_LI_ref); //here it says no such interface supported
  6. }
Up to this the whole code works in Mozilla but not in IE.

if i change the code like this ....
Expand|Select|Wrap|Line Numbers
  1. var child_LI_ref = opener.document.createElement('LI');
Then it works in both ;)
May 6 '09 #5
16,027 Expert Mod 8TB
If you're going to stick to the same document, then it will work. If not, you should be using importNode, but unfortunately, it's not been implemented in IE though you can find versions online.
May 6 '09 #6

Post your reply

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

Similar topics

6 posts views Thread by Cortes | last post: by
9 posts views Thread by Ken | last post: by
1 post views Thread by James Hallam | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.