Closed Bug 293326 Opened 20 years ago Closed 20 years ago

iframe onload handler fires when new page is loaded inside

Categories

(Core :: DOM: Core & HTML, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: vlad, Unassigned)

Details

Attachments

(1 file)

Bug 292691 relies on having loader() fire when the XXX link is clicked, in: <iframe onload="loader()"><a href="http://foo/">XXX</a></iframe> Attachment demonstrates the calling of the function.
vlad tested IE, it does the same (and set the de-facto standard here, AFAIK). This is unusual. Ever since I promulgated "DOM level 0" (it was all just "JavaScript" then), you could preset onload on a window or frame and then load something in it, and your onload would run (with the usual same-origin security checks, in bugfixed browser releases ;-). But once you loaded a second page, the first page's event handlers, including any preset (via an HTML attribute, or an assignment statement before the first page was loaded) handlers, would be cleared. Where is the code in our tree that makes a special case for iframe onload, to preserve it across the second load? /be
> Where is the code in our tree that makes a special case for iframe onload, to > preserve it across the second load? The handler is set on the <iframe> HTML element, not on the window inside the iframe. So changes to the window inside the iframe don't affect the existence of the handler. No special handling necessary there. The special handling to _fire_ the handler is http://lxr.mozilla.org/seamonkey/source/dom/src/base/nsGlobalWindow.cpp#941
Right, we talked about this, and it just shows how old I am that I don't treat iframes as different from frames, but they are (the element is akin from an event handling point of view to a single-frame frameset element, if such a thing were possible). /be
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Oh, and can't framesets nest? If so, the same could in theory be done with a nested frameset, it could have an onload handler and *it* could fire when a child frame is loaded. Not that I've tested this, but I just thought about it and realized that it'd probably work with nested framesets too. But either way, that's per design, I'd say.
Group: security
Flags: in-testsuite?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: