[thelist] JavaScript Multiple Events

Christian Heilmann codepo8 at gmail.com
Thu Jul 5 07:10:45 CDT 2007


> You can call more than one function from a single event.  Just
> separate them with a semicolon.
>
> <a href="" onmouseover="alert('one');alert('2');">this is a test</a>

Not very advisable as this can easily become a maintenance nightmare
(not even talking about inline event handlers, what is this, 2001?).
Better to use a wrapper method:

<a href="" onmouseover="hover(this)">this is a test</a>

function hover(o){
 func1(o);
 func2(o);
}

How to avoid all of this altogether:
http://onlinetools.org/articles/unobtrusivejavascript/chapter2.html

-- 
Chris Heilmann
Book: http://www.beginningjavascript.com
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/



More information about the thelist mailing list