Closed Thread Icon

Topic awaiting preservation: cloneNode and IFrames in IE, bad juju methinks. (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=8449" title="Pages that link to Topic awaiting preservation: cloneNode and IFrames in IE, bad juju methinks. (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: cloneNode and IFrames in IE, bad juju methinks. <span class="small">(Page 1 of 1)</span>\

 
genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 12-31-2002 14:06

Hi.
Not much activity here lately.
Well since cloning is hot news, here's a cloneNode problem to chew on.

I have an iframe that has a premade node in it, i want to copy that node and put it in my main document.
Simple cloneNode, appendChild yes yes? apparently no.

at least not in IE.
As per usual, it works for me in Moz, but IE chokes without much in the way of help other than "Invalid Argument".

check it.

code:
function showLib() {
//get div to append node to, make it visible.
var lib = document.getElementById("thelib");
lib.style.visibility = "visible";
//get my iFrame document
var imglib = window.frames["libFrame"].document;
//get preferred iframe node
var yip = imglib.getElementById("imglib");
//clone it
var clone = yip.cloneNode(true);
//append it in main div
lib.appendChild(clone);
}

So... it works in Mozilla. Why not in IE?
I tried using some innerHTML tricks in IE, but they didn't seem to work for me.

Perhaps I can get an example up on the site for ya to peruse in a bit.
Thanks for any help. =)

edit: example up here --> http://web.sweetastic.com/ozone/

[This message has been edited by genis (edited 12-31-2002).]

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 12-31-2002 14:32

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 12-31-2002 14:42

been there, done both of those things.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 12-31-2002 15:10

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 12-31-2002 15:23

Yeah i had read that, but it seemed to me they were talking about directly copying an iframe node, rather than something inside the document contained within the frame.

At least, that's what the example seemed to show.
At any rate, I tried it anyway, and couldn't get it going. several ways.

I've got an example up now... here --> http://web.sweetastic.com/ozone/

just click on the button that says "CLICKY DIS HERE!"
Please disregard all the other fallacies... its old but it shows my problem.

In Moz it should work fine, and in IE it should give you the error around line 106, which is the appendChild line.
Of course, I'm sure its a combination that is causing the problem, as you can see I'm using all sorts of appendChild statements in the other scripts on the page.

Thanks for checking for me.

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 12-31-2002 15:55

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 12-31-2002 16:53

okay, screw it.

File this one under "Impossible" (i'd file it under "IE sucks" but that one's full).

I even went so far as to put a function in the iframe document that cloned the node and returned it, and then called the function from the main document, and still I get the same error.

Oh the humanity!!

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 12-31-2002 16:56

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 12-31-2002 17:02

Maybe a workaround to achieve the same goal, but i swear i've tried everything in the cloneNode category.

I say nap-time, then workaround time.

it is so and so it is.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 12-31-2002 19:36

I played around with this for a bit. So far, the best I've come up with is to replace the lib.appendChild(clone) line with

lib.innerHTML += clone.innerHTML;

if you choose to use this workaround, best to do something like

if (document.all)
lib.innerHTML += clone.innerHTML;
else
lib.appendChild(clone);

Interestingly, clone *does* behave like a regular node in all other senses... if you loop through its properties ("for (prop in clone) ...") you get them all, so IE does recognize it as a node. It's just "tainted" or something since it came from an IFRAME. I dunno.

genis
Paranoid (IV) Inmate

From: Dallas, TX
Insane since: Aug 2002

posted posted 01-01-2003 00:59

Yep... it is certainly tainted or something.

Thanks for the workaround!

I sure do find all the weird fallacies in IE's javascript engine... this one.. the removeChild not working in a for loop one...

i should document them and put em on a page somewhere at least.

oh well, thanks for all the help!

« BackwardsOnwards »

Show Forum Drop Down Menu