The three main things that you can do with client-side scripting are:
Interact with the client
Validate data entry
These tasks are accomplished by manipulating the MSIE Document Object Model (DOM). We’ll examine each of these uses in turn.
First, let’s take a look at a small script that displays a message to the user when the web page loads, as shown in Figure 8.2; its HTML source is shown in Example 8.5. Don’t worry about the code now; we’ll take a more in-depth look at it later.
Example 8-5. A Little VBScript Interactivity
<HTML> <HEAD> <Script Language = "VBSCRIPT"> sub window_onload msgbox "Welcome to my Website" end sub </SCRIPT> </HEAD> <BODY> <H1>Matt's Wonderful World of Web</H1> </BODY> </HTML>
This simple example will pop up a message box to the client when the page loads in the window. Not too complex, but a nice touch— and more importantly, not something you can do without a scripting language. Let’s take a little closer look at what is happening here.
Figure 8-2. Web page produced by Example 8-5
First, we declare the subroutine in the
<HEAD> section of the HTML page. This
isn’t required, but we highly recommend it as good practice.
Better to have all of your code in one place so you can find the
subroutines faster when you need to make corrections or changes.
The next section is the actual ...