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 CSS Drive when clicked on:
<form> <input type="button" value="Click here!" onClick="window.location='http://cssdrive.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 CSS Drive while alerting to the surfer a message, all at the same time. How's how.
- Tutorial introduction
- One event handler, one action
- One event handler, many actions
- JavaScript cut-and-pasters, listen up!