Script You Can Use

As of December 2011, this topic has been archived. As a result, it is no longer actively maintained. For more information, see Archived Content. For information, recommendations, and guidance regarding the current version of Internet Explorer, see Internet Explorer Developer Center.

Robert Hess
Microsoft Corporation

September 13, 1999

I've recently received a lot of questions about this, so I thought it would be a good idea to share with the budding "scripters" out there information to help them get past some of the problems and confusion they might be facing.

I talk with a lot of different people who are working on developing applications, Web sites, and specifically "Web applications." As I've discussed in the past, the evolution of Web applications is drawing the fairly static Web-based document into the realm of an interactive application. This means that Web site designers need to think more and more like applications programmers.

Web designers entering the programming arena may experience a slightly awkward stage, as they learn some of the strange nuances of application programming that might be second nature to a traditional programmer. One of the key concepts that virtually all programmers face early on is the separation of "programming language" from "application environment." By this I mean that the programming language you are using is just something that describes the "structure" or "form" that your instructions need to follow in order to be understood by the interpreter or compiler that you are using. The programming language often doesn't provide much in the way of actual functionality, or user interface itself, perhaps just some rudimentary methods for conducting input and output.

To illustrate this a little better, let's take a (very!) simple example program written in the C language. This is the classic "Hello, world" program:

#include <stdio.h>
   printf ("Hello, world.\n");

You almost can't get simpler than this, but even here, we are relying on functionality that isn't directly supplied by the programming language. The printf function, while one of the most common functions used in C, isn't really part of the programming language. Instead, it is part of one of the standard libraries of functions. This is why it was necessary for our example to use:

#include <stdio.h>

This is where we told the compiler how to evaluate printf properly. Granted, any implementation of C that didn't include support for printf would be considered incomplete. It is still important to realize that the functionality of printf isn't actually part of the programming language, but instead comes from a library of functions that are provided by the vendor of the compiler.

In the same way, a lot of the functionality gained from the script code you put onto your Web pages isn't directly supplied by the script language you are using. Most of the functionality gained is directly dependent on what is being exposed by the Web browser, and not by the scripting language itself. This means that in addition to understanding the form and syntax of the scripting language, you also need to understand how to access the functionality provided by the environment in which your script is being run.

By going to, you can find documentation and references for Jscript® and Visual Basic® Scripting Edition (VBScript) that will assist you in understanding the syntax of the language, as well as the built-in functions that are provided. But when you try to add script code to your Web pages, you won't get very far with just that information. You also need to know of the other tools that are at your disposal, specifically what objects are included with the browser, how to access them, and what properties, methods, and events they expose for your usage.

Click "show TOC", then scroll to and click the "DHTML References" option in the left-hand table of contents. This will give you access to the documentation for the various levels of functionality exposed by Internet Explorer. The key areas for you here are the first four:

  • Objects
  • Properties
  • Methods
  • Events

While objects provide the base from which almost everything happens, in and of themselves they really aren't that exciting. You'll probably find yourself spending the most time in the "Methods" and "Properties" sections, which list all of the methods and properties exposed by the various objects contained within Internet Explorer. Browse through these listings until you find something that sounds interesting, click on it, and find out from where it is coming.

To make your browsing as productive as possible, you'll need to understand early on the difference between a property and a method. A property is a value—a number, name, or some other setting that you can either "set" or "retrieve" (or often both). Some common properties exposed by many objects include height, width, color, and name. A method is something that normally will instigate additional processing or functionality. Some common methods that you might use are click (which will cause the object being referenced to behave as if it had been clicked by the user), blur (which will cause the object being referenced to lose its focus, or deselect itself), and scrollIntoView (which will cause the referenced object to be scrolled into view on the page).

The specific question that prompted this article was from a Web author who had downloaded the VBScript and JScript documentation; try as he might, he couldn't find any information on how to access or use the "print" capability from a Web page even though he had heard that it was available. The problem is that he was looking in the wrong place. The right place was in the above-mentioned list of methods. By looking through the list, you can clearly see that the print method is exposed by the window object, and to call it, you use the form:


Often, simply by looking through the list of available methods and properties, you can get ideas on how to achieve some form of special functionality in your application. I highly recommend that all Web designers familiarize themselves with these pages, so that they can better understand the tools at their disposal.

Robert Hess is an evangelist in Microsoft's Developer Relations Group. Fortunately for all of us, his opinions are his own.