Closed
Bug 498904
Opened 15 years ago
Closed 14 years ago
Javascript: window.frames['name'] broken when removing and adding iframe
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 350023
People
(Reporter: fabian.lange, Unassigned)
Details
Attachments
(1 file)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090615 Firefox/3.5 (.NET CLR 3.5.30729) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090615 Firefox/3.5 (.NET CLR 3.5.30729) Lets say we have a page that dynamically adds iframes to show information. because the user shall print them out there is a print button that does window.frames['name'].print(). This does work in all browsers, but in none of my tested firefox builds (2-3.5rc) however window.frames.length is always 1. and additionally window.frames[0].print() does work always as well. My assumption is that the named registry still refers to the old no longer existing iframe, eventhough the new one is there already. See attached html to reproduce Reproducible: Always Steps to Reproduce: 1. Open Testscript, press the "rebuild iframe" button once. (note that inner.html needs to exist) 2. Press "show location" 3. Press "rebuild iframe" again 4. Press "show location" again Actual Results: 1. an iframe is created 2. the url of inner.html is displayed 3. the iframe is deleted and recreated 4. nothing happens Expected Results: 1.-3. same 4. again the url is displayed The workaround is: var myFrame; for (i=0; i < window.frames.length; i++) { if (window.frames[i].name == 'myIframe') myFrame=window.frames[i]; } but the original bug could also indicate a memory leak
Reporter | ||
Comment 1•15 years ago
|
||
Same thing occurring for me. I actually created a very similar test page to demonstrate that closely resembles yours... <html> <head> <title>FF Bug</title> <script languague="Javascript"> function createFrame() { if (document.getElementById('if1') != null) document.body.removeChild(document.getElementById('if1')); var el = document.createElement("iframe"); el.setAttribute('id', 'if1'); el.setAttribute('name', 'if1'); document.body.appendChild(el); } function checkFrame() { alert(window.frames['if1'].location.href); } </script> </head> <body> <input type="button" value="Create Frame" onclick="createFrame();" /> <input type="button" value="Check Frame" onclick="checkFrame();" /> </body> </html>
Comment 3•15 years ago
|
||
This bug may be related to these bugs?: Bug 350023 - Named items of window.frames collection can include frames that have been removed from the document Bug 415870 - window.frames[name] persists after iframe is removed from the DOM Bug 427254 - Unable to access iframe over window.iframe_name after adding it with innerHTML for the second time
Updated•14 years ago
|
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Comment 4•14 years ago
|
||
YEah, indeed.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
Assignee | ||
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•