W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2003

RE: What should the "load" event be attached to?

From: Philippe Le Hegaret <plh@w3.org>
Date: 02 Jun 2003 14:21:47 -0400
To: Ian Hickson <ian@hixie.ch>
Cc: WWW DOM <www-dom@w3.org>
Message-Id: <1054578107.7994.29.camel@jfouffa.w3.org>

> The DOM2 Events specification appears to be unclear about exactly
> which objects the "load" event applies to.

This has been (hopefully) clarified in the DOM Level 3 Events
specification.

> In a pure XML context, is it the root element, or the document itself,
> that receives this event?

The load event can be dispatch to an Element node:
http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/events.html#Events-EventTypes-complete

> In an (X)HTML context, does the body element get the event?

Given the compatibility between XHTML 1.0 and HTML 4, the list of
possible targets for the load event is:
[[
HTMLBodyElement, HTMLFrameSetElement, HTMLObjectElement,
HTMLLinkElement, HTMLMetaElement, HTMLScriptElement, HTMLFrameElement,
HTMLIFrameElement, HTMLImageElement
]]
http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/events.html#Events-eventgroupings-htmlevents

> If the latter, then how does one attach a load event to a document
> before the body node has been loaded into the document? (As is common
> with load events, since the document is typically not going to be
> fully loaded when the event is attached.)

The load event, as defined in HTML 4 using the onload attribute, was
designed for the FRAMESET and BODY elements. We extended the concept in
DOM to address other "objects". I believe that your functionality is
addressed in the Load and Save module:
[[
Events supported by asynchronous DOMBuilder objects are:
 * load: The document that's being loaded is completely parsed, see the
   definition of LSLoadEvent
 * progress: Progress notification, see the definition of
   LSProgressEvent
]]
http://www.w3.org/2003/05/WD-DOM-Level-3-LS-20030509/load-save.html#LS-DOMBuilder

In other words, the target is not the Document, but the object used to
build the Document.

> Some clarifications to the DOM2 Events specification would be very
> useful.

Correct, it would be good to put it on our errata list for DOM Level 2
Events at some point. We are giving priorities to DOM Level 3 for the
moment (over DOM Level 1 Second Edition or DOM Level 2 errata).

Philippe
Received on Monday, 2 June 2003 14:21:50 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:57 GMT