VBScript Events - VB Script

What is an Event ?

VBScript's relations with HTML are handled in the course of events that take place when the user or browser controls a page.

When the page loads, that is an event. When the user clicks a button, that click too is an event. Another example of events are like pressing any key, closing window, resizing window, etc.

Developers can use these events to implement VBScript coded responses, which cause buttons to close windows, messages to be displayed to users, data to be validated and practically any other type of response conceivable to occur.

Events are a part of the Document Object Model (DOM) and every HTML element has a certain set of events, which can activate VBScript Code. Please go through this small tutorial for a better understanding HTML Event Reference. Here, the relation between Event and VBScript can be seen through examples below.

Onclick Event Type

This is the most regularly used event type, which takes place when a user clicks mouse's left button. You can put your confirmation, warning, etc., against this event type.

Example

This will produce the following result, and when you click Hello button, then onclick event will occur which will trigger sayHello() function.

onsubmit event type

Another most essential event type is onsubmit. This event occurs when you try to submit a form. So you can put your form confirmation against this event type.

The Form is submitted by clicking on Submit button, the message box appears.

Example

OUTPUT

onsubmit event type

These two event types will help you to create good effects with images or even with text as well. The onmouseover event happens when you bring your mouse over any element and the onmouseout happens when you take your mouse out from that element.

Example

This will produce a result when you float the mouse over the text box and also when you move the focus away from the text box and the button.

HTML 4 Standard Events

The standard HTML 4 events are listed here for your reference. Here, script indicates a VBscript function to be executed against that event.

Event
Value
Description
onchange
script
Script runs when the element changes
onsubmit
script
Script runs when the form is submitted
onreset
script
Script runs when the form is reset
onblur
script
Script runs when the element loses focus
onfocus
script
Script runs when the element gets focus
onkeydown
script
Script runs when key is pressed
onkeypress
script
Script runs when key is pressed and released
onkeyup
script
Script runs when key is released
onclick
script
Script runs when a mouse click
ondblclick
script
Script runs when a mouse double-click
onmousedown
script
Script runs when mouse button is pressed
onmousemove
script
Script runs when mouse pointer moves
onmouseout
script
Script runs when mouse pointer moves out of an element
onmouseover
script
Script runs when mouse pointer moves over an element
onmouseup
script
Script runs when mouse button is released

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

VB Script Topics