Scripts are extremely useful for making your Web pages dynamic. In fact, in the old days of ASP, this is how you accessed COM objects and provided custom results to users.
The following shows an example of the HTML for using a script:
<html>
<head>
<script language="javascript" src="Test.js">
</script>
<title> This is a basic Web Page! </title>
</head>
<body>
<input type="button" value="Click Me"
onclick="ThrowDialogBox('Hello World')"/>
</body>
</html>
In this example, the Test.js file includes the following Java script code:
function ThrowDialogBox(str)
{
alert(str);
}
There are numerous events that you can handle with scripts. Table 21-3 shows some of these events.
|
Event |
Description |
|---|---|
|
onload |
Browser loads an object |
|
onkeydown |
User presses a key |
|
onkeyup |
User releases a key |
|
onmousedown |
User presses a mouse button on an object |
|
onmouseover |
User moves a pointer over an object |
|
onclick |
User left-clicks an object |