Any valid ECMA 262 script expression can be used to be evaluated each time an event fires. This example shows how to bind inline code as an event handler.
<img src="sample1.gif"
onmouseover="this.src='sample2.gif'"
onmouseover="this.src='sample1.gif'">
In that example, we define ECMA-compatible code and assign it directly to the inline event attributes of an IMG element. Whenever either the onmouseover or onmouseout event occurs on the object, the code is evaluated and executed. The handler applies only to the specific element where it is declared.
This method is convenient as long as the code is relatively short and uncomplicated. If you use an inline attribute in this way, you should also use the language attribute to specify the scripting language for the code. If not specified, either the default language or the most recent language specified is assumed. For example:
<button language="JavaScript"
onclick="alert ( 'Hello World!' )">Click Me</button>
which displays the message "Hello World!" when a user clicks on the BUTTON element.