6.3.2. event object

During normal program execution, a large number of events occur, so the event object is a fairly active object, constantly changing its properties.  Whenever an event fires, the computer places appropriate data about the event into the event object – for example, where the mouse pointer was on the screen at the time of the event, which mouse buttons were being pressed at the time of the event, and other useful information.  Skilled use of the event object can be very rewarding.  It opens up possibilities for creating very intricate and complex programs.  HTML and JavaScript  provides the event handling capability.  JavaScript consider every event as an object and hence with some properties.  The properties.  The properties of the event object contain the information about the event.

Example 6.4 – Click event object

A click event occurs when the user clicks the left button  0f the mouse.  In the following example, a message is displayed when the user clicks the button in the document.

<html>
<head>
<title> script event</title>
<script type = “text/ JavaScript”>
Function dispMsg(ev)
{
Var msg = “A” + ev.type+”event”
Msg+= “on mouse button” + ev.which
Msg+= “.\n\r”
Document.tstForm.TextArea.value+- = msg
}
</script>
</head>
<body>
<form name = “tstForm”>
<p> <input type = “button” name = “TestBtn” value = “Click Me”
OnClick =dispMsg(event)>
<p> <textarea name = “TextArea” rows= 10 cols =20 wrap =”physical”> </textarea>
</form>
</body>
</html>
Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

One Response to “6.3.2. event object”

  1. gold account says:

    Whenever an event fires, the computer places appropriate data about the event into the event object – for example, where the mouse pointer was on the screen at the time of the event, which mouse buttons were being pressed at the time of the event, and other useful information.

Leave a Reply

Your email address will not be published. Required fields are marked *


four × 6 =

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter