[thelist] Events

Diego webmaster at sci-web.com.ar
Fri Nov 1 13:36:01 CST 2002


Hi all,

----- Original Message -----
From: "Chris Marsh" <chris at webbtech.co.uk>
Sent: Friday, November 01, 2002 3:41 PM
Subject: [thelist] Events


> > I have a number of elements on a page, each with an id. I
> > want certain javascript functions to fire on certain events,
> > but I don't want to specify event handlers in any tags nested
> > within (but not including) the body. If I have a function
> > Init() that fires on page load, is there some way I can do
> > the following (the code is incorrect and for illustrative
> > purposes only):
> >
> > function Init() {
> >   var foo = document.getElementById("bar");
> >   foo.onClick = alert("Eureka!");
> > }

Yes it can be done, only you need to write "onclick", not "onClick", which
will throw an error. The same goes for "onMouseOver" (element.onmouseover),
onmouseout, onload, onunload, etc

regards,
Diego.



> >
> > Many thanks in advance...
> >
> > Regards
> >
> > Chris Marsh




More information about the thelist mailing list