Mary Haggard
Program Manager
Microsoft Corporation
May 9, 1997
The following article was originally published in Site Builder Magazine (now known as MSDN Online Voices).
You've spent time playing around with Web technologies and have figured out how to use HTML commands to draw tables and frames, specify color, place images, determine fonts, build style sheets, and generally control what's happening on your page. Now you're thinking: There must be something more.
How can you make the page more active? How can your user interact with your Web site? How can you tell what browser a user has and generate content accordingly? How can you add a form to your site and have it gather data? How do you control Java and ActiveX? This time, we're going to talk about building scripting functionality into your basic Web site.
High-performance scripting languages allow you to achieve everything listed above and more. Best of all, many of the scripting languages now widely in use allow you to leverage your existing skillset quickly, resulting in oohs and ahhs from your coworkers and site visitors. We'll discuss the basic scripting languages, tools, and resources available to help you build solutions, and how you can leverage the code you write across the most users. As always, plenty of pointers to helpful resources are included.
In your search to find this article, you clicked through many script-filled pages on the MSDN online siteincluding this one. For instance, we used script the first time you visited the site to set up the controls. Scripting also tells us what browser you are using and which version; scripting allows us to communicate with the Site Builder database that contains your name and password; and scripting is used to manipulate the controls that make up the Site Builder navigation bar (those six clickable categories near the top of this page, just beneath "For Starters").
Visual Basic® Scripting Edition (VBScript) is a subset of the Visual Basic Programming Language and is implemented in Microsoft Internet Explorer and Microsoft Internet Information Server. The language itself has the same syntax as Visual Basic, and it is 100 percent compatible with Visual Basic (that is, you can cut and paste code to Visual Basic and back). One important note: VBScript is intended to be a safe subset of the language; therefore it does not include file input/output or direct access to the underlying operating system. VBScript allows you to control the browser, link controls to pages, automate Java applets, and link forms to databases. VBScript is supported in the latest versions of Microsoft Internet Explorer for Windows® 95, Windows NT®, Windows 3.x, and the Macintosh®. VBScript is not supported in the current versions of Netscape Navigator®.
Microsoft's extendable, open implementation of JScript is 100 percent compatible with the JavaScript implementation in Netscape Navigator®. JScript allows developers to link and automate a wide variety of objects in Web pages, including ActiveX controls and "applets" created using Java. If you are familiar with the syntax of C or C++, JScript programming should be fairly straightforward for you. JScript is supported in the latest versions of Microsoft Internet Explorer for Windows 95, Windows NT, Windows 3.x, and the Macintosh.
Because the implementations of VBScript and JScript are fairly similar, it is relatively easy to program in both, optimize for all browsers, or change code from one to the other. You can also have both languages performing actions on the same HTML page. HTML code and script code sit together on each HTML page.
Here is some sample code that produces a simple message box written in both Jscript and VBScript. The sample is running in Jscript.
<SCRIPT LANGUAGE="JavaScript"> <!-- function Press_OnClick () { alert("It's really this easy!") } //--> </SCRIPT> <P> <FORM Name="Form1"> <INPUT TYPE=BUTTON VALUE="Click me" NAME="BtnHello" OnClick="Press_OnClick()"> </FORM>
<SCRIPT LANGUAGE="VBScript"> <!-- Sub Press_OnClick () alert("It's really this easy!") End Sub --> </SCRIPT> <P> <FORM Name="Form1"> <INPUT TYPE=BUTTON VALUE="Click me" NAME="BtnHello" OnClick="Press_OnClick()"> </FORM>
Active Server Pages (ASP) scripting technology is written for and performed by the server side of your Web site. You can use ASP technologies to do many of the same functions that VBScript and Jscript can do on the client side, including determine user browsers, manipulate ActiveX and Java components, and build many different kinds of functions. What sets ASP technology apart from client-side scripting is its ability to combine with ActiveX Server Components (such as the Active Data Object) to create dynamic content and Web-based database applications. ASP scripting is also browser independent. Because pages are built on the server side and sent to the browser, you don't need to worry about which browser can speak which scripting language.
Because ASP can work closely with database applications, it can cut the need for scores of HTML pages within a Web effort by combining database and/or user input to dynamically generate pages. Check out how one company, Network Imaging Corporation improved its process and gained a competitive edge by tying together ASP technology and database applications. More information about ASP technology is available on the Microsoft BackOffice Web site as well as the MSDN Online Web Workshop's Server area.
Dynamic HTML (DHTML) is one of the most exciting things to come along in Web technology. Microsoft has proposed a standard for DHTML to the World Wide Web Consortium, and most new versions of Web browsers will support these new technologies. DHTML functionality in the browser allows you to create Web pages and other documents that automatically and instantly adapt to specific users, to user requests, and to the changing state of data from sources on the Web and other locations. Using the scripting language of your choice, you can access and manipulate all elements of a Web pagetags, attributes, images, objects, and textcreating, moving, and modifying these elements as needed.
You can download Internet Explorer 4.0 . Be sure to check out the growing set of information on Internet Explorer 4.0 technologies in other sections of the Workshop, specifically the DHTML, HTML & CSS area in the MSDN Online Web Workshop. The Dynamic HTML Gallery also showcases features such as structured graphics, databinding, outlining, and version control.
Scripting is quickly becoming one of the most widely used technologies on the World Wide Web. In addition to the sites I mention above, check out some of the resources listed here.
Microsoft's VBScript and JScript sites contain documentation and samples.
A great example of complex scripting is on Alpenglow's On Safari site, which makes creative use of the Browser Kiosk mode, the HTML Layout Control, Java applets, and VBScript.
The AdventureWorks sample Web site can help you learn more about ASP capabilities.
Microsoft Internet Technology Mailing Lists include peer support for VBScript and ASP technologies. Discussions are just starting to heat up about Dynamic HTML.
Several Microsoft tools are available to help you build scripting into your Web applications. They include Visual Interdev, with authoring and debugging support for VBScript, JScript and ASP; FrontPage , supporting VBScript and JScript authoring; and the Microsoft Script Debugger to help you debug VBScript and JScript in Internet Explorer.
Since taking early retirement as commander of the Starship Enterprise and joining Microsoft, Mary Haggard has worked her way through the ranks to her lifelong goal, being Program Manager for the MSDN Online Web publishing team. Mary once worked in a paper mill, so she knows pulp when she sees it.
If you're already well on your way to implementation, a great place to direct very specific technical questions is to the Web Men Talking, MSDN Online's new "Answer Guys."