Modify ↓
Ticket #10736 (closed bug: invalid)
iframe load event
| Reported by: | Math. | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | event | Version: | |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
jQuery does not handle load event for iframe which are not yet added to the document as you can do with img.
Test case: http://jsfiddle.net/5KK7w/
Works: $('body').append('<iframe id="iframe1"/>'); $('#iframe1').load(function(){
alert('iframe loaded');
}).attr({'src':srcIframe});
Does not work: $('<iframe id="iframe1"/>').load(function(){
alert('iframe loaded'); $(this).appendTo('body');
}).attr({'src':srcIframe});
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

If you watch the network traffic, you can see that the iframe src is not retrieved until the iframe is appended to the body. Therefore, it has not yet loaded as an image would.