469,331 Members | 1,754 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

CloneNode doesnt work. Why?

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 <scriptand <linknode 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?

Dec 14 '06 #1
1 2271
ASM
bs****@gmail.com 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.wanado...nerHTML_danger

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 14 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Petr Felzmann | last post: by
reply views Thread by Sullivan WxPyQtKinter | last post: by
2 posts views Thread by Csaba Gabor | last post: by
4 posts views Thread by Olorin | last post: by
3 posts views Thread by santosh.pjb | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.