W3C home > Mailing lists > Public > public-html@w3.org > December 2008

RE: online/offline events and bubbling

From: Adrian Bateman <adrianba@microsoft.com>
Date: Wed, 31 Dec 2008 09:04:19 -0800
To: Jonas Sicking <jonas@sicking.cc>
CC: Ian Hickson <ian@hixie.ch>, public-html <public-html@w3.org>
Message-ID: <749F45FA745A3244A87A63316D4E26B1719535BF4C@NA-EXMSG-C108.redmond.corp.microsoft.com>

On 30 Dec 2008, Jonas Sicking wrote:
> On Tue, Dec 30, 2008 at 6:46 PM, Adrian Bateman <adrianba@microsoft.com>
> wrote:
> > Currently, IE only fires on the body. Firefox fires on body, then
> document, then window. Opera fires on window then document. I'm not sure
> if Webkit supports these events. It appears, then, that there is currently
> no consensus and if we are to make and test a change for IE8 we'd like to
> ensure we will all end up in the same place. If this isn't an issue that
> will be addressed soon then we'll likely stick with the behaviour we have
> now and look again in a future release when things are settled.
> When you say that Firefox fires at body, then document, then window,
> you mean that we fire a single event at the body which then bubbles to
> the document and window, right?
> If Opera fires on window then body, does this mean that they are
> firing two non-bubbling events? This seems possible, but unnecessarily
> complicated to me.
> IMHO only a single event should be fired, where to fire it and if it
> should bubble is of course a good question.

Of course. I probably wasn't precise enough with my language - I didn't test for bubbling or not so I meant that the event is seen by event sinks at the places above. I would assume it's due to bubbling in Firefox - certainly the text in Bugzilla points to that being the design.

I think the difference between IE8 and Firefox currently is that IE8 doesn't bubble. I'm not sure what is happening in Opera. The code I used to test is below.

function main() {
    if(window.attachEvent) {
	    // Register ononline listeners
	    window.attachEvent("ononline", function(){log("window.ononline")});
	    document.attachEvent("ononline", function(){log("document.ononline")});
	    document.body.attachEvent("ononline", function(){log("document.body.ononline")});
	    // Register onoffline listeners
	    window.attachEvent("onoffline", function(){log("window.onoffline")});
	    document.attachEvent("onoffline", function(){log("document.onoffline")});
	    document.body.attachEvent("onoffline", function(){log("document.body.onoffline")});
	} else {
	    // Register ononline listeners
	    window.addEventListener("online", function(){log("window.ononline")},false);
	    document.addEventListener("online", function(){log("document.ononline")},false);
	    document.body.addEventListener("online", function(){log("document.body.ononline")},false);
	    // Register onoffline listeners
	    window.addEventListener("offline", function(){log("window.onoffline")},false);
	    document.addEventListener("offline", function(){log("document.onoffline")},false);
	    document.body.addEventListener("offline", function(){log("document.body.onoffline")},false);
Received on Wednesday, 31 December 2008 17:07:22 UTC

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