VBScript Tutorials - Herong's Tutorial Examples - v6.02, by Herong Yang
Event Listeners and Objects
This section provides a quick description of event trigger attributes on different HTML tags and the 'event' object representing the event with detail information about the event. A tutorial example is provided to display mouse location by adding a listener to the mouse-pushed-down event.
IE browser also supports special HTML attributes to let you add event listeners and passing event objects. Here are few commonly used HTML attributes on various HTML tags:
More event trigger attributes will be introduced in other chapters in this book.
To illustrate some nice features of event triggers, I wrote this VBScript tutorial example:
<html> <!-- Event_Listener_and_Trigger.html - Copyright (c) 1998 HerongYang.com. All Rights Reserved. --> <head> <title>Event Listener and Trigger</title> <script type="text/vbscript"> function mouseDown() window.alert("Mouse pushed down!") end function </script> </head> <body onMouseDown="mouseDown()" language="vbscript"> <p>Click anywhere on the page to see a message.</p> </body> </html>
In this tutorial example, the "onMouseDown" event trigger attribute on the "body" tag is used to add a short listener code to be executed when the user push down the mouse button on the page.
A message is reported back to the user with an alert box by calling the "alert()" method on the "window" object. See the picture below:
Table of Contents
Introduction of VBScript - Visual Basic Scripting Edition
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
►IE Web Browser Supporting VBScript
VBScript Support in IE Web Browsers
Including VBScript Code with HTML "script" Tags
Including VBScript Code as External Files
DOM API - The "document" Object
'vbscript:' Pseudo-URL Addresses