tamarintech
tamarintech

Reputation: 1992

parentNode returns a window object in Firefox but a div object in Chrome

Here is some example code:

frames = document.getElementsByTagName('iframe');
parent = frames[0].parentNode;
parent.removeChild(frames[0]);

Works in Chrome/Webkit as a userscript. The iframe disappears. However, in Firefox, I will get an exception that parent has no function "removeChild" and that parent is OBJ Window.

Why? How do I work around this?

Upvotes: 1

Views: 348

Answers (1)

epascarello
epascarello

Reputation: 207527

Is frames a global variable? If so you are running up against window.frames which contains references to all of the frames on the page.

Rename the variable to something else and see if the problem goes away.

Upvotes: 2

Related Questions