[thelist] [JavaScript] Event question for you event experts

Matt Warden mwarden at gmail.com
Mon Feb 20 14:58:41 CST 2006


Hi Tom,

On 2/20/06, Tom Dell'Aringa <pixelmech at yahoo.com> wrote:

> addObjectEventListener('myObjID', 'load', funct);
>
> and it didn't work. For the yahoo one, I'm doing

That's a good point. It would be useful to allow for simply passing an
ID. The way it is currently set up, you must pass the object, e.g.:

var foo = document.getElementById('foo');
if (foo) addObjectEventListener(foo, 'load', funct);

> function fnCallback(e) { alert("loaded"); }
> YAHOO.util.Event.addListener("address2", "load", fnCallback);
>
> And I get absolutely nothing. It works for click - but not load.
>
> Thanks for your script - it will definitely work for me. I would like to get the yahoo one running
> too and see what applies to us better. I feel like if I understood why it works for click and not
> load, I'd have a better handle on things.

Only images, documents, and the window object have a load event (and
maybe layers). You need to either place the javascript after the input
tag in the markup (a bit ugly), add the function to window.onload, or
use a technique which essentially checks ever x milliseconds whether
the element is part of the DOM yet. Yahoo's lib might do this.
Otherwise take a look at Open JSAN's DOM.ready
(http://openjsan.org/doc/a/au/autarch/DOM/Ready/0.13/lib/DOM/Ready.html)
or domready (http://www.brothercake.com/site/resources/scripts/domready/)


--
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the thelist mailing list