W3C home > Mailing lists > Public > public-webapi@w3.org > March 2006

Re: ACTION-70: Define the scope chain of onFoo events reference issue-1

From: Sergey Ilinsky <sergey@backbase.com>
Date: Wed, 15 Mar 2006 12:13:22 +0100
Message-ID: <015a01c64821$792a3e10$8132a8c0@vientiane>
To: "\"Web APIs WG (public)\"" <public-webapi@w3.org>
Hello,

> 3) The current order of handlers execution is different in different browsers 
>    (take onload event that is first handled on window and then on body in IE, while fired first on body and then on window in Mozilla)

A test case for the problem mentioned:

IE:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<script>
window.attachEvent("onload", function(){alert('window')})
</script>
</HEAD>
<BODY onload="alert('body')">
</BODY>
</HTML>

Gecko:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<script>
window.addEventListener("load", function(){alert('window')}, false)
</script>
</HEAD>
<BODY onload="alert('body')">
</BODY>
</HTML>

In IE you will get 'body', 'window' (probably bug)
In Gecko: 'window', 'body'

This wrong order happens to IE only when the handler is attached within <head> section. once you moved your script to <body> everythng gets correct

But in any case, has the mechanism of "moving" event handlers from body/html tags to window object been defined?
Since there are several ways of achieving the desired effect (order of handlers processing), there should also be the definition of the logic done.
Will the handlers be moved to window, to document? Or the event will be dispatched with the target <body /> ?

Sergey Ilinsky,
Core Architect,
BackBase B.V.
Received on Wednesday, 15 March 2006 11:13:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:53 GMT