CloneNode doesnt work. Why?

B

bs9999

Can someone please tell me why when i use <object>.clondeNode that when
I appendChild it to my document, the new node doesnt properly work? I'm
making a clone of a <script> and <link> node from an iframe on my page.
The cloned node looks fine, and even appends to my document fine.
Viewing innerHTML confirms it is appart of my document. The problem is
when i do something like alert(myTestVar), where myTestVar was
originally a javascript variable declared within the iframe <script>
tag (the iframe cloned node), i get back an undefined error. The only
way this will work is if i do a document.createElement and manually
copy the innerHTML, and attributes of the original node, then
appendChild -- now Javascript will present the proper value for the
variable.

Can someone explain to me whats happening? Maybe despite the node being
cloned, it is still apart of some other "document" (the iframe) and so
cant be appended to the new, different document? Is there a way around
such a thing?
 
A

ASM

(e-mail address removed) a écrit :
Can someone explain to me whats happening? Maybe despite the node being
cloned, it is still apart of some other "document" (the iframe) and so
cant be appended to the new, different document? Is there a way around
such a thing?

I have not such problem cloneNoding from main window to a popup,
but I only tried with div in the body whom the alone cloned JS is what
is in onclick and so on.

Do you use :
truc = blah.cloneNode(true); ? (with 'true')
and
foo.appendChild(truc); ?

because innerHTML gives various results :-(

http://stephane.moriaux.perso.wanadoo.fr/truc/innerHTML_danger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top