Categories:
Partners

One event handler, one action

Just to make sure everyone's on the same page, allow me to first demonstrate an example where one event handler performs only one action. Below is a button that goes to CNN when clicked on:

<form>
<input type="button" value="Click here!" onClick="window.location='http://codingforums.com'">
</form>

That's all great and dandy, and for the most part, is all you'll need an event handler to do- one task. However, there will be the occasional time when you'll need the event handler to be a little more ambitious, and perform many tasks at once, like go to CodingForums while alerting to the surfer a message, all at the same time. How's how.

Copyright 1997-2014 JavaScript Kit. NO PART may be reproduced without author's permission.