W3C home > Mailing lists > Public > public-html@w3.org > September 2007

load event for dynamic iframes - firing when changing the frame's location

From: Michael A. Puls II <shadow2531@gmail.com>
Date: Tue, 4 Sep 2007 21:56:15 -0400
Message-ID: <6b9c91b20709041856v61194217s253055f3cd558e3@mail.gmail.com>
To: public-html@w3.org
When you create an iframe with innerHTML or createElement and the
iframe has an onload attribute set (or .onload = function or
addEventListener), when the iframe is added to the document, the js in
the onload attribute is executed in FF, Safari and Opera.

Now, after the iframe is added to the document, if you change the
location (via .src or .location or by submitting a form that targets
the iframe, whether the js in the iframe's onload attribute fires
again depends on what browser you're using.

In FF and Safari, it is not fired again. In Opera it is.

So, basically, FF and Safari do not fire a load event for the location
change of dynamic iframes. Opera does.

Now, for changing the location of parsed iframes, Safari does the same
as it does with dynamic ones and doesn't fire.  Firefox however, does
fire and so does Opera.

So, Opera is consistent with itself for dynamic or parsed iframes.
Safari is consistent with itself also. They are not however consistent
with each other.  FF isn't consistent with itself.

Drupal's drupal.js seems to (or did) count on FF and Safari's behavior
for location changes of dynamic iframes, but are they correct, or is
Opera's way correct? (Opera's way seems expected to me.)

Attached is a createElement demo. The alert fires twice in Opera and
once in Safari and FF.


Received on Wednesday, 5 September 2007 01:56:26 UTC

This archive was generated by hypermail 2.4.0 : Saturday, 9 October 2021 18:44:21 UTC