469,289 Members | 2,211 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

Append Child working in Mozilla but not in IE.

dmjpro
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
  4.  
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 4503
Ciary
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>
  3.  
May 6 '09 #2
acoder
16,027 Expert Mod 8TB
You need to use imporNode.
May 6 '09 #3
dmjpro
2,476 2GB
@Ciary
Here you directly setting the innerHTML. I am talking about the document.createElement ;)
May 6 '09 #4
dmjpro
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. }
  5.  
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. }
  7.  
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');
  2.  
Then it works in both ;)
May 6 '09 #5
acoder
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
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.