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

RESOLVED DUPLICATE of bug 350023

Status

()

Core
DOM: Core & HTML
RESOLVED DUPLICATE of bug 350023
10 years ago
9 years ago

People

(Reporter: Colin Finck, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

10 years ago
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

Updated

10 years ago
Status: UNCONFIRMED → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 350023

Updated

10 years ago
Duplicate of this bug: 436505

Updated

9 years ago
Component: DOM: HTML → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.