The web pages today need to be more and more interactive and useful for the user. To make this interaction possible the web developer needs “events”, an event are the basic building blocks for developing an interactive dynamic web page. For example, selecting input box in html page, submitting a form to server by clicking on submit button, mouse click, keystroke, mouse hovering the link, web page loading. With the help of events the web pages become livelier giving the feeling of control to the users.
Onclick create event when a particular text button link clicked on. Following script will compile the idea of onclick event.
Listing 1: Script of Onclick event
Figure 1: Above figure is output of onclick event script which is showing a pop up message after clicking the “Click Here!” button.
Onsubmit Event:The Onsubmit event occurs when the submit button in a form is clicked. After submitting the form the details will send to server or wherever desired. Following script will compile the idea of Onsubmit event.
Listing 2: Script to Onsubmit Event
Figure 2 and 3: Above two figure is output of Onsubmit event, which accepts user Email ID and password. If the password enter first time and password enter second time is same then it will show a successful message and send data to destination or server otherwise will open an alert message. Validation checking also checks the length of entered Email ID and password.
The OnMouseOver Event facilitates the web developer to change the graphics or appearances of any element on the web page when mouse hovers over it. This is also used to initiate a function. Following script will display the exact meaning of OnMouseOver Event.Listing 3: Script of OnMouseOver Event
onFocus, onBlur events These event handlers are typically used with Form elements, such as text fields, radio buttons, and submit buttons, checkboxes. onFocus is triggered when the cursor is placed on or within a specific form element. onBlur is triggered when the cursor leaves a form element.