A simple example of a VBScript page
Use Microsoft (R) Internet Explorer to view the following HTML codeCreated page. If you click the button on the page, you can see the running result of VBScript.
<HTML><HEAD><TITLE>
A simple Homepage</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Button1_nClick
MsgBox "Hello, world!"
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<H3>
A simple Homepage</H3><HR>
<FORM><INPUT NAME="Button1" TYPE="BUTTON" VALUE="
Click here"></FORM>
</BODY>
</HTML>
The result is a bit simple: a dialog box displays a Latin phrase (meaning "looks pretty "). However, this Code actually does many things.
When Internet Explorer reads the page, it finds the <SCRIPT> mark to identify the VBScript code and save the code. When you click the button, Internet Explorer connects the button to the code and runs the process.
<SCRIPT> MARKSubA process is an event process. The process NAME consists of two parts: one part is the button NAME, that is, Button1 (obtained from the NAME attribute in the <INPUT> tag), and the other part is the event NAME, that is, nClick. The two parts are connected by underscores. When you click the button, Internet Explorer searches for and runs the corresponding event process, that is, Button1_nClick.
Internet Explorer defines events that can be used for Form Controls in the Internet Explorer Scripting object model document, which can be found (http://www.microsoft.com) on the Microsoft (R) Web site ).
You can also use a combination of controls and processes on the page. VBScript and the form display some simple interactions between controls.
Other methods for appending code to an event
The above method may be the simplest and most commonly used, but you can also use the other two methods to attach VBScript code to the event. One way is to add shorter internal code to the tag of the definition control. For example, when you click the button, the following <INPUT> MARK performs the same operation as the previous example:
<INPUT NAME="Button1" TYPE="BUTTON" VALUE="
Click here" nClick='MsgBox "Mirabile visu."'>
Note that function calls are included in single quotes,MsgBoxThe function string is enclosed in double quotation marks. Multiple statements can be used as long as the statement is separated by a colon.
Another way is to specify specific controls and events in the <SCRIPT> tag:
<SCRIPT LANGUAGE="VBScript" EVENT="nClick" FOR="Button1"><!-- MsgBox "Mirabile visu."--></SCRIPT>
Because the <SCRIPT> flag specifies events and controls, you do not need to use them again.SubAndEnd SubStatement.