Closed
Bug 780864
Opened 12 years ago
Closed 12 years ago
Second dynamic iframe with same name loses listeners
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 170799
People
(Reporter: dimhold, Unassigned)
Details
Attachments
(1 file)
1.73 KB,
application/octet-stream
|
Details |
User Agent: Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1 Build ID: 20120713134347 Steps to reproduce: I dynamically create iframe on the button click: document.getElementById("iframeContainer").innerHTML = '<iframe name="iframeName" id="iframe" src="iframe.html"/>'; I add listener to the iframe's button (when iframe loaded): frames["iframeName"].document.getElementById("iframeButton").addEventListener("click", function () { console.info("main: click"); }); On the first iframe creation I see "main: click", but on the second creation - the click listener doesn't work. Ugly workaround: create iframe with unique name: document.getElementById("iframeContainer").innerHTML = '<iframe name="iframeName_' + (new Date()).getTime() + '" id="iframe" src="iframe.html"/>'; Also I guess this case eats up memory. I'm attaching a simplified test case. Reproducible: Always Steps to Reproduce: 0) Open main.html from attached archive. 1) Click the "Create iframe [innerHtml]" or "Create iframe [createElement]" button. 2) Click the "Click me" button 3) Look at console: iframe: click ; main: click - OK!!! 4) Click the "Create iframe [innerHtml]" or "Create iframe [createElement]" button AGAIN. 5) Click the "Click me" button AGAIN. 6) Look at console: iframe: click - One event listener? --> BUG!!! Actual results: 1) listener does not invoked. 2) iframe 'load' event doesn't fire (I also added listener by setTimeout - doesn't work too) Expected results: 1) The second dynamic iframe with same name should works as the first dynamic iframe.
![]() |
||
Comment 1•12 years ago
|
||
It works if remove property by delete command, before adding iframe to dom tree. + delete frames[iframeName]; document.getElementById("iframeContainer").innerHTML = iframeHtml; + delete frames[iframeName]; document.getElementById("iframeContainer").appendChild(iframe);
![]() |
||
Updated•12 years ago
|
Component: Untriaged → DOM
Product: Firefox → Core
Version: 14 Branch → Trunk
Comment 2•12 years ago
|
||
Related to bug 350023?
![]() |
||
Comment 3•12 years ago
|
||
Yes, related like a duplicate... Of bug 170799, really.
Status: UNCONFIRMED → RESOLVED
Closed: 12 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
•