The click MethodCalling an object's click method is almost the same as triggering a click event for the objectbefore Netscape Navigator 4.0 and Internet Explorer 4.0; however, this method did not call the object's onclick event handler. You can see the support for this method in Table 6.12. Table 6.12. The click Method
Here's an example; in this case, when you click the second button in this page, the first button's onclick event is triggered: (Listing 06-04.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.click() } // --> </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> |