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:

<!-- Event_Listener_and_Trigger.html
 - Copyright (c) 2015, HerongYang.com, All Rights Reserved.
<title>Event Listener and Trigger</title>
<script type="text/vbscript">
function mouseDown()
   window.alert("Mouse pushed down!")
end function
<body onMouseDown="mouseDown()" language="vbscript">
<p>Click anywhere on the page to see a message.</p>

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:

Window Alert Box
Window Alert Box


Table of Contents

 About This Book

 Introduction of VBScript - Visual Basic Scripting Edition

 Variant Data Type, Subtypes, and Literals

 Arithmetic Operations

 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

 Built-in Functions

 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

 VBScript Support in IE Web Browsers

 Including VBScript Code with HTML "script" Tags

 Including VBScript Code as External Files

 DOM API - The "document" Object

 DOM API - The "window" Object

Event Listeners and Objects

 'vbscript:' Pseudo-URL Addresses

 IIS ASP Server Supporting VBScript

 WSH (Windows Script Host)


 Full Version in PDF/EPUB