Previous Example-|-Next Example-|-Return to Chapter Listing

Example 12.20:
Passing event Object Information to a Handler Function

[This example works with Netscape Navigator 3 or Internet Explorer 3. It will not work with Internet Explorer 3.]

The button and link in this page pass the event information to a function, which displays information in a secondary window. Click the button or point at the link.

This is an onmouseover link. Point anywhere in this link and the event information will be passed to the function. Point anywhere in this link and the event information will be passed to the function. Point anywhere in this link and the event information will be passed to the function.
In the HEAD we have this script: <SCRIPT language="javascript"> <!-- function handle(e) { propwin = window.open("","win","width=350,height=400,scrollbars=1,resizable=1,alwaysRaised") propwin.focus() propwin.document.open() propwin.document.write("<form><input type='button' Value='Close this Window' onclick='self.close()'></form>") propwin.document.write("The event handler received this type of event:<BR><B>" + e.type + "</B><P>") var prop; for(prop in e) { propwin.document.writeln("&nbsp;&nbsp;" + prop + " = " + e[prop] + "<BR>" ); } } //--> </SCRIPT> In the BODY of the page we have this: <FORM> <INPUT TYPE="button" VALUE="Open Window" onclick="handle(event)"> </FORM> <A HREF="Javascript:void(null)" onmouseover="handle(event)"> This is an onmouseover link. Point anywhere in this link and the event information will be passed to the function. Point anywhere in this link and the event information will be passed to the function. Point anywhere in this link and the event information will be passed to the function.</A>
Previous Example-|-Next Example-|-Return to Chapter Listing