Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
double-click.<br />
onmouseover. Runs when the mouse pointer is over a certain part of the<br />
page.<br />
onkeypress. Runs when you press a specific key on the keyboard.<br />
onchange. Runs when the contents of part of a form changes.<br />
onblur. Runs when you press the tab key to switch between part of a form.<br />
onsubmit. Runs when the form's submit button is pressed.<br />
What are these events useful for? All sorts of things. The onmouseover<br />
function, for example, can be used to rewrite parts of the page's code when<br />
the user hovers over something – useful for providing pop-up help 'tooltips'.<br />
Onkeypress lets you give the user keyboard shortcuts to do things on your<br />
web page. Onblur and onsubmit can be used very effectively to spot errors<br />
in a user's form input, and let the user know how to correct them before<br />
they're ever even sent back to the server.<br />
Once you know which event you want to tie some JavaScript to, you have to<br />
say so in your code. You can do this in one of two ways. The first way is to<br />
directly attach it to the HTML element in question, like this:<br />
<br />
This works well, but has the disadvantage of polluting your HTML with<br />
JavaScript function names. The second, better, way, is to do it like this in the<br />
JavaScript itself:<br />
onload = function() { }<br />
This creates a function directly from an event (in this case, the onload event),<br />
without ever touching the HTML itself.<br />
JavaScript Commands.<br />
Here's a quick reference to the most useful commands in JavaScript.<br />
The Web Design Guide for Newbies |78