Closed Bug 427254 Opened 16 years ago Closed 16 years ago

Unable to access iframe over window.iframe_name after adding it with innerHTML for the second time

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 350023

People

(Reporter: mail, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9pre) Gecko/2008040504 Minefield/3.0pre
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9pre) Gecko/2008040504 Minefield/3.0pre

I have an empty <div> tag with the id "test" here.

Now I add an <iframe> to this element using JavaScript and innerHTML: document.getElementById("test").innerHTML = '<iframe name="foo"></iframe>';
I can now access the document element of this <iframe> using window.foo.document.

But when I now set innerHTML again to '<iframe name="foo"></iframe>' on the same page, window.foo.document will only return null.

I can reproduce this problem with Minefield (Gecko/2008040504) and Firefox 2.0.0.13.
This doesn't occur with Opera 9.26, Safari 3.1 and IE 7.

You can try it yourself on the test page at http://colinfinck.de/Mozilla-innerHTML-Bug/. Click "Go" here for the first time and you'll receive "[object HTMLDocument]". All subsequent calls will only return "null".

Reproducible: Always
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
Component: DOM: HTML → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.