[thelist] Modularity and the DOM

Dan Phiffer dphiffer at hmc.edu
Tue Jul 9 13:48:02 CDT 2002


According to the W3C DOM, the correct way to capture events such as mouse
clicks is to use the addEventListener function. In all the examples I've
found, the common practice is to add event listeners from the onload event
for the entire document (i.e. <body onload="addEvents()">).

This is somewhat problematic for me since my documents are split into
numerous modular files included together in PHP. The file that contains
the <body> element for the document may not necessarily also contain the
elements that need event listeners.

I realize there are other ways of capturing these events such as <element
onmouseup="foo()">, but in Mozilla I haven't found a way to get access to
the event object (for mouse coordinate info, etc.) without using the DOM
event listener method.

Any thoughts?

Relevent links:
http://www.mozilla.org/docs/dom/domref/dom_el_ref31.html
http://www.w3.org/TR/2002/WD-DOM-Level-3-Events-20020208/ecma-script-binding.html

TIA,
-Dan


.: ICQ 22573428 .:. AIM DanAtMudd .:. http://phiffer.com :.




More information about the thelist mailing list