Open Bug 236547 Opened 21 years ago Updated 3 years ago

Cannot attach events to IFRAME if it is created with createElement function

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
Windows XP
defect

Tracking

()

UNCONFIRMED

People

(Reporter: jorgen, Unassigned)

References

()

Details

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007 If you take a look at this URL: http://www.nextavenue.com/mozilla/bug/iframe/ You see two examples; one does work fine and the other does not. The only difference is how the IFRAME is created. If you take a look at the code it will become clear immediately. Attaching events to an IFRAME seems not to work if it is created with DOM functions. Reproducible: Always Steps to Reproduce: 1. Create a new IFRAME element 2. Append it to the body 3. Try to Attach any event Actual Results: You can click as much as you want, the event will not be fired... Expected Results: The event should have fired There is no easy workround since I must create the IFRAME with DOM functions... I am reprogramming my Editor and want to make it Mozilla compatible.
Dupe of bug 231578??
The problem is that the document you're adding the event handler to ceases to exist. When you create the iframe, it starts an asynchronous about:blank load. you attach the listener, then the load finishes and replaces the document. Simply changing that line to: setTimeout('document.getElementById("frame").contentWindow.document.addEventLister("mousedown", foo, true)', 0); Makes things work.
An no, it's not a dup of bug 231578, since the event listener is NOT set on the iframe. It's set on the .contentWindow.document of the iframe.
Depends on: 227028
I figured out there is no problem if you change the ID to: "blabla" instead of "frame"... Odd, is FRAME a prohibited keyword? I have found a solution; attach the events when the onload event fires :) Using the setTimeout is not a solid solution (I tried, now and then the problem still occured)
This is an automated message, with ID "auto-resolve01". This bug has had no comments for a long time. Statistically, we have found that bug reports that have not been confirmed by a second user after three months are highly unlikely to be the source of a fix to the code. While your input is very important to us, our resources are limited and so we are asking for your help in focussing our efforts. If you can still reproduce this problem in the latest version of the product (see below for how to obtain a copy) or, for feature requests, if it's not present in the latest version and you still believe we should implement it, please visit the URL of this bug (given at the top of this mail) and add a comment to that effect, giving more reproduction information if you have it. If it is not a problem any longer, you need take no action. If this bug is not changed in any way in the next two weeks, it will be automatically resolved. Thank you for your help in this matter. The latest beta releases can be obtained from: Firefox: http://www.mozilla.org/projects/firefox/ Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html Seamonkey: http://www.mozilla.org/projects/seamonkey/
This bug has been automatically resolved after a period of inactivity (see above comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → EXPIRED
Bugs with useful comments from bz and dependencies from danm shouldn't expire.
Status: RESOLVED → UNCONFIRMED
Resolution: EXPIRED → ---
Hi! I am experiencing a simular bug!!! If I move or replace an Iframe Object, I can not access javascript functions in the iframe document anymore!!! When moving an outer object (div) in wich the iframe is placed you can do it one time and it will work, but if you move the outer object div again it will fail!!! here is the site on wich I am testing: www.dwergpapegaai.com You can post a message, and then try to reply to the message you posted (message is implemented via AJAX). It won't work, in IE all possible solutions work fine! Please help!
Assignee: events → nobody
QA Contact: ian → events
Component: Event Handling → User events and focus handling
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.