The fireEvent Method


The fireEvent Method

The fireEvent method is much like the dispatchEvent method (see the previous topic), except fireEvent is an Internet Explorer-method only. You can see the support for this method in Table 6.19.

Table 6.19. The fireEvent Method

Method

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

fireEvent( event [, eventObject ])

               

x

x

 

Returns: Boolean

You pass this method the name of the event you want to "fire" (that is, trigger), and you can optionally pass an event object that you want to hold the data for this event. Here's an example where I'm causing an onclick event in a button:

(Listing 06-05.html on the web site)
 <HTML>      <HEAD>          <TITLE>Using the click Method</TITLE>          <SCRIPT LANGUAGE="JavaScript">              <!--             function alerter()              {                  alert("You clicked the button!")              }  function clicker()   {   document.form1.button1.fireEvent("onclick")   }  // -->          </SCRIPT>      </HEAD>      <BODY>          <H1>Using the click Method</H1>          <FORM NAME="form1">              <INPUT TYPE="BUTTON" NAME="button1" ONCLICK="alerter()" VALUE="Click Me!">              <INPUT TYPE="BUTTON" ONCLICK="clicker()" VALUE="Click the Other Button!">          </FORM>      </BODY>  </HTML> 

This method returns a value of true if the event was triggered successfully, and false otherwise .



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net