The fireEvent MethodThe 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
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 . ![]() |