Find out how the Event object can be used to manipulate the dimensions of a Web page and intercept keyboard and mouse events
| Back To Basics |
An event may be defined, very simply, as an action performed on a Web page - for example, clicking a button, moving the mouse pointer over a hyperlink and so on.
An event handler, as the name suggests, handles an event - it defines the action to be taken by a script when a particular event (or type of event) occurs. Event handlers exist for most of the common events that are generated on a Web page, including mouse movement, mouse clicks, keyboard activity and page loads.
Here's a quick example that might make this theory a little clearer:
onClick - invoked when the user clicks the specified object
onMouseOver - invoked when the user passes the mouse over the target object
onMouseOut - invoked when the mouse pointer leaves the target object
onSubmit - invoked when the user clicks the Submit button in a form
onChange - invoked when the user changes the contents of a text field
onSelect - invoked when the user selects the contents of a text field
onReset - invoked when the user clicks the Reset button in a form
onLoad - invoked when the target image or document is loaded
onUnload - invoked when the target image or document is unloaded
With all this information at your disposal, it's fairly easy to write client-side scripts that take advantage of it to do new and cool things on your Web page. I'll be showing you a few shortly - but first, take a look at a brief sampling of the properties that a typical Event object exposes:
''.preg_replace(array('/ /', '/ /'), array(' ', ' '), '
Property Description (compatibility)
type returns a string value indicating the event type
x returns the horizontal position of the cursor relative to the object
y returns the vertical position of the cursor relative to the object
height returns the height of the object (NN)
width returns the width of the object (NN)
modifiers returns the details of any modifier keys that were held down during a key or mouse event
which returns integer value indicating which mouse button or key was pressed (NN)
keyCode returns Unicode value of the key pressed (IE)
button returns integer value of the mouse button pressed (IE)
Intrigued? Let's do something useful, then.
How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.
Read more, or grab your copy now!