VBScript Tutorials - Herong's Tutorial Examples - Version 5.24, by Dr. Herong Yang
Using VBScript with Internet Explorer
This section provides tutorial example on how to embed a VBScript code in a HTML document to be executed by Internet Explorer on the client machine.
Internet Explorer (IE) is a Microsoft application that can be used a Web browser to view Web pages. IE also supports a VBScript host environment that allows you to embed VBScript codes into source codes of Web pages - HTML documents.
VBScript codes embedded in HTML documents will be executed while IE is rendering HTML documents on the browser window. This is also called client side scripting, because script codes are executed on the client machine instead of the server machine.
To add VBScript codes into your HTML documents, you need to use the "script" tag with the "language=vbscript" attribute. Inside the "script" tag, you can place any number of VB statements. Here is the syntax of adding VBScript codes in HTML documents:
... (HTML tags) <script language=vbscript> ... (VB statements) </script> ... (HTML tags)
Now let's try to write our first VBScript code in a HTML document.
1. Open the Notepad to enter the following HTML document:
<html> <body> <script language="vbscript"> document.write("Hello world! - VBScript in IE") </script> </body> </html>
2. Save the HTML document as hello_vb.html.
3. View the HTML document with IE. You should see the following message in the IE window:
Hello world! - VBScript in IE
Congratulations. You have successfully written a VBScript code for the host environment supported in IE!
What happened here was:
Table of Contents