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

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.

-- 
Michael

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