- Shopping Bag ( 0 items )
With the advent of client-side scripting, it is possible to create programs that run on a user's browser in response to particular user actions, like passing the mouse over a hyperlink or clicking a standard HTML command button. By taking advantage of client-side scripts, web pages can be made more interactive, and programs that ran as (usually CGI) applications on the server before client-side scripting can now execute on the browser, in the process improving the performance of...
With the advent of client-side scripting, it is possible to create programs that run on a user's browser in response to particular user actions, like passing the mouse over a hyperlink or clicking a standard HTML command button. By taking advantage of client-side scripts, web pages can be made more interactive, and programs that ran as (usually CGI) applications on the server before client-side scripting can now execute on the browser, in the process improving the performance of a web site's web pages.
In Learning VBScript, Paul Lomax shows how to take full advantage of client-side scripting using Microsoft's own scripting language, Visual Basic Scripting Edition, or VBScript. Learning VBScript consists of three distinct sections that quickly teach the reader how take advantage of client-side scripting to enhance a web site's pages:
In focusing on techniques for creating professional, scripted web pages,
Learning VBScript includes chapters on the following:
The CD-ROM accompanying Learning VBScript includes over 170 code samples, and allows you to retrieve examples by category; you can, for instance, retrieve hyperlinks to all the web pages that include ActiveX controls. In addition, the CD-ROM includes a complete shopping cart application that can be easily customized for your own needs.
Whether you're a content provider who wants to add client-side scripts to web pages or a Visual Basic programmer who wants to begin creating web applications, Learning VBScript is the definitive guide that takes you through the rudiments of the language and covers the techniques needed to develop professional web pages.
Tutorial and guide for client-side scripting using VBScript in the Microsoft Internet Explorer object model environment. Emphasizes interactivity and Web site enhancement through dynamic documents, browser data validation and embedded ActiveX controls. Introduces VBScript as a client-side Web application development tool. Guides you through syntax and structure of VBScript, explains script tags, program flow, browser control, and HTML intrinsic controls. Shows how to add ActiveX controls to applications and gives a tutorial example of a layout control. Discusses date and time controls, hyperlink options and Web page communication. Explains image maps and dynamic HTML pages. Investigates form-input validation, error handling and debugging techniques. CD-ROM contains hyperlinked code examples and a complete shopping cart application. A very good, logically-organized tutorial that goes beyond scripting basics and into professional web page design concepts.
Above all, VBScript brings to us true client-side processing, so let's briefly look at some of the main uses of VBScript:
Reference and Manipulate Document Objects
Document objects, or, to give them their correct title, intrinsic HTML objects, are the display objects we currently use time and again in our HTML code, usually within the INPUT tag, to create forms. VBScript gives us the ability to access the properties of these objects (for example, to determine the value typed into an input text box by the user). Not only do we have access to these properties, we can also use VBScript to set the values of these properties. For example, we could set the value of an HTML text box to a particular value-perhaps to the current date and time on the client machine-as the page loads.
With normal HTML code, you can set the VALUE attribute of a text box just as easily. But unless you build your HTML source code from a script on the server (using an older technology like server-side includes, or a newer one like server-side VBScript with Active Server Pages), any value must be "hardcoded" into your HTML document. For instance, to continue with our date and time example, you could include the following line in your HTML document so that your web page displays the date and time:
INPUT TYPE=text NAME=txtTime VALUE="2/3/97 12:01:00 PM"
But unless you update your page immediately before each user accesses it, the date and time displayed when a user's browser displays the page is going to become increasingly inaccurate. Rather than using hardcoded HTML, you could instead use CGI to transmit the current date and time to display on a client machine. This is, however, the time on the server machine, and not the time on the client machine; in some cases (on slow Internet connections, in periods of heavy traffic, and, of course, in cases where the Internet server is in a different time zone than the client), the web page ends up displaying a date and time that may be more or less inaccurate. And a basic problem is that, whether you hardcode the date and time into your HTML document or whether you generate it "dynamically" through a CGI application, once the page is displayed, the value of the date and time becomes fixed.
How does VBScript help with some simple task like displaying the date and time? VBScript not only supports the standard document objects, it also allows us to attach events to these objects. To put this another way, when the user or another part of our program interacts in some way with a particular object, like a command button, the browser can automatically run a particular routine within our program. For example, if the user clicks on a certain button or moves away from a text box, an "event" is fired that causes a particular routine to execute.
The HTML code in Example 1-1 illustrates how easy it is to display the current date and time on the client machine when the document is loaded. It also allows the user to update the date and time by pressing the Update Time button.
Example 1-1: Using VBScript to display the date and time
H3 Welcome to my Web page! /H3
Reference and Manipulate the Browser
To VBScript, the browser itself is an object; in fact, it is several objects, all of which have properties. Using VBScript, you can control things such as the browser's history list and its status bar. You have tight control over how frames are handled within the browser window. You can check and reset the location or the URL, and automatically navigate to another page or even another web site. Let's say an application has one main document and two secondary documents, and that which of the two secondary documents you load depends on a combina- tion of responses from the user to the primary document (much more complex than simply clicking on a hyperlink). Automatically handling that decision process and retrieving the chosen document is an ideal job for VBScript. You can also call other VBScript programs in other frames and windows within the browser, and even open new browser windows at will, while controlling the appearance of the window at the same time. Chapter 5, Controlling the Browser, and Chapter 6, The Element Object and HTML Intrinsic Controls, provide an in-depth look at the objects exposed by the browser.
Example 1-2 contains a very simple script that controls the browser's status bar. When the user clicks the Click Me button, a VBScript routine generates a random number. If its value is less than .5, the text "Here's some text in the status bar" appears in the status bar; if its value is greater than .5, any text in the status bar is removed....
|2||What Is VBScript?||35|
|4||Program Flow and Structure||113|
|5||Controlling the Browser||159|
|6||The Element Object and HTML Intrinsic Controls||220|
|7||Using the ActiveX Control Pad||260|
|8||The HTML Layout Control||280|
|9||An HTML Layout Common Menu Object||296|
|10||Data and Time in VBScript||306|
|11||Describing Your Hyperlinks||345|
|12||Image Maps Made Easy||359|
|13||Building Dynamic HTML Pages||370|
|14||Form Input Validation||392|
|15||Error Handling and Debugging||424|
|16||The VBScript Shopping Cart||457|
|17||Handling Other Browsers||495|
|A||VBScript 1.0 Language Quick Reference||521|
|B||VBScript Version 2||534|
|C||VBScript 2.0 Intrinsic Constants||553|
|D||ActiveX Controls Quick Reference||558|
|E||Active Server Pages||567|
|F||The Learning VBScript CD-ROM||579|