• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Using Web Scripting

Web pages commonly use scripting languages to define actions and objects accessible from within a browser. The most common languages in use are JavaScript (Microsoft's version is called JScript) and VBScript (Visual Basic Script). To add JavaScript or VBScript code to a new Web page, do the following:

Choose Tools, Macro, Microsoft Script Editor from the menu. Or use the keyboard shortcut, Alt+Shift+F11. The Microsoft Script Editor opens up as shown in Figure 24.21, although with a different view from that in typical HTML source viewing.

Figure 24.21. Adding script code to a Web page using the Microsoft Script Editor.

If the Script Editor is not already installed, you will be prompted to install it; follow the prompts.


The Script Editor view for typical HTML source (refer to Figure 24.8) does not open the Toolbox, Properties window, or Project Explorer window used to create or edit scripting code as shown in Figure 24.21.

To choose the default language (either VBScript or JavaScript) in which to write a script, choose View, Property Pages from the menu (Shift+F4 from the keyboard). This affects scripts for which you do not explicitly specify a language. As shown in Figure 24.22, you can choose between VBScript and JavaScript (ECMAScript) for the Client.

Figure 24.22. Choosing the scripting language to use in a Web page.


JavaScript is the more universally supported language. VBScript works only in Internet Explorer, not in Netscape Navigator.


Client-side scripts execute within the browser after the Web page has loaded; they are self-contained.

The scripting language can also be changed in the Properties window of the Script Editor under defaultClientScript.

After you've selected a scripting language, scroll to the insertion location in the Web page. Right-click and choose Insert Script Block, Client. This command is also available from the menu under Edit, Insert Script Block, Client.

A typical blank scripting container for JavaScript would appear as follows:

<script language=javascript>



Those symbols <!-- and //--> are used to enclose comments in HTML, so the HTML interpreter portion of a Web browser will not read them. This leaves other interpreters such as VBS or JavaScript free to claim them as their own and run them when the page loads.

After the container is created, you can start typing code.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint