VBScript
Microsoft Visual Basic Scripting Edition (VBScript) is a case-insensitive subset of the Microsoft Visual Basic language that is upwardly compatible with Visual Basic for Applications. VBScript is supported by Microsoft Internet Explorer. The VBScript Interpreter is fast, portable, and can be freely licensed from Microsoft. Because Visual Basic is a widely known language with thousands of developers worldwide, the learning curve for VBScript is very short.JavaScript
JavaScript is implemented by Microsoft as JScript. It is a C-like language that is based on Java, a programming language developed by Sun Microsystems and Netscape. JavaScript is supported by Netscape Navigator and Internet Explorer.NoteTo aid your development efforts, Microsoft has provided a tool, called the Microsoft Script Debugger, as a free add-on for Microsoft Internet Explorer. The Script Debugger provides debugging features for Web applications and works with both JavaScript and VBScript.
Only subtle variations in syntax define the difference between the two languages. Neither is compiled, and both will run on any hardware platform. Both languages are interpreted, so speed differences are a result of the Web browser and not of the language itself.
When choosing a scripting language, consider the following issues:
The user's Web browser must include a scripting interpreter for the scripting language you use. Microsoft Internet Explorer has interpreters for both VBScript and JavaScript. Netscape Navigator provides an interpreter for JavaScript. Users can acquire a Netscape plug-in to support VBScript.
Use the scripting language that you are most familiar with. If you have Visual Basic experience, you can quickly learn VBScript. If you have Java or C experience, JavaScript will be more familiar to you.
NoteYou can use VBScript and JavaScript together on the same page by setting the LANGUAGE parameter.
Example
This example, written in VBScript, runs when the user clicks the corresponding button in the Web page:<SCRIPT LANGUAGE="VBScript"> <!-- Sub BtnHello_OnClick() MsgBox "Hello, world!" End Sub --> </SCRIPT>
NoteWeb browsers that do not understand scripting code display the code in the HTML page as regular text. To prevent this, place scripting code in comment tags (<!-- and -->).
When the Web browser gets to the <SCRIPT> tag, it calls the VBScript interpreter to compile the code. In the preceding example, the code is associated with the Click event of a button named btnHello and the output is written in a message box.
Example
This example defines a general function that is called by other procedures within the Web page. The quantity ordered ( txtQty ) is passed to the function. If the quantity exceeds 100 units, a discount is applied to the order:<SCRIPT LANGUAGE="VBScript"> <!-- Function Discount(txtQty) If txtQty > 100 then Discount = .10 End Function --> </SCRIPT>
When writing scripting code, place all of your code within the same <SCRIPT> tag. Although your HTML page can contain more than one <SCRIPT> tag, the code is easier to maintain when it is located in the same tag. You can place the <SCRIPT> tag in either the BODY or the HEAD sections of the HTML page.
To use client-side scripting, you include the source code within an HTML document. When a Web browser encounters script within the HTML, it calls a scripting interpreter, which parses and deciphers the scripting code.
Microsoft Visual Basic Scripting Edition (VBScript) and JavaScript are two common scripting languages. VBScript is a subset of the Microsoft Visual Basic language, and is supported by Microsoft Internet Explorer.