Chapter 7. Events


As an event-driven programming language, JavaScript does very little on its own; instead, it waits for the user to do something, and then reacts by executing a bit of script.

In order to find out what's going on in the HTML page, the DOM supports events. Every time the user takes an actionfor instance, she clicks on a link, submits a form, loads a new page, changes the value of a form field, or presses a keyan event fires.

You can add event handlers to any elements. Event handlers are functions that are automatically executed when the event takes place on that element. If the script is well thought out, the page responds to user actions and interactivity is born.

All example scripts in this book are event-driven: they kick in only after the user takes an action that I, as the programmer, have decided is most logical in the context. For instance, Dropdown Menu waits for the user to mouse over or focus on certain links, Form Validation waits for the user to submit the form, and XMLHTTP Speed Meter waits for the user to enter a postal code.



ppk on JavaScript. Modern, Accessible, Unobtrusive JavaScript Explained by Means of Eight Real-World Example Scripts2006
ppk on JavaScript. Modern, Accessible, Unobtrusive JavaScript Explained by Means of Eight Real-World Example Scripts2006
ISBN: N/A
EAN: N/A
Year: 2005
Pages: 116

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net