Using VBScript with Internet Explorer 10 or Older
This section provides tutorial example on how to embed a VBScript code in a HTML document to be executed by Internet Explorer 10 or older on the local 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 code into source code of
Web pages - HTML documents.
VBScript code 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 code is executed on the client machine
instead of the server machine.
To add VBScript code 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 code in HTML documents:
... (HTML tags)
... (VB statements)
... (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:
document.write("Hello world! - VBScript")
2. Save the HTML document as hello_vb.html.
3. View the HTML document with IE 10.
You should see the following message in the IE window:
Hello world! - VBScript
Congratulations. You have successfully written a VBScript code
for the host environment supported in IE!
What happened here was:
- We have added a "script" tag in our HTML document, hello_vb.html.
- We included a simple VBScript code inside the "script" tag.
- The VBScript code calls the "document.write" function,
which is a function provided by the IE host environment
to insert a text string into the HTML document.
- We ran IE to view hello_vb.html and got exactly what we expected.
- If you are using IE 11, you need to follow the next tutorial to turn on ActiveX
- If you are using other Web browsers, like Edge, Chrome, or Firefox,
you will see a blank page, because they do not support VBScript.
Table of Contents
About This Book
►Introduction of VBScript - Visual Basic Scripting Edition
What Is VBScript?
►Using VBScript with Internet Explorer 10 or Older
Using VBScript with Internet Explorer 11
Using VBScript with Internet Information Services
Using VBScript with WSH (Windows Script Host)
Using Visual Basic with Microsoft Access
VBScript and Supporting Environments
Variant Data Type, Subtypes, and Literals
Numeric Comparison Operations and Logical Operations
String Operations - Concatenation and Comparison
Variable Declaration and Assignment Statement
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Array Data Type and Related Statements
Array References and Array Assignment Statements
Conditional Statements - "If ... Then" and "Select Case"
Loop Statements - "For", "While", and "Do"
"Function" and "Sub" Procedures
Inspecting Variables Received in Procedures
Error Handling Flag and the "Err" Object
Regular Expression Pattern Match and Replacement
scrrun.dll - Scripting Runtime DLL Library
Creating Your Own Classes
IE Web Browser Supporting VBScript
IIS ASP Server Supporting VBScript
WSH (Windows Script Host)
Full Version in PDF/EPUB