1 <HTML> 2 3 <HEAD> 4 5 <TITLE>JavaScript Example: Event object</TITLE> 6 7 <SCRIPT LANGUAGE="JavaScript1.2"> 8 9 function myOnMouseDown( e ) { 10 var msg = "Event type: " + e.type; 11 msg += "\nx position: " + e.layerX; 12 msg += "\ny position: " + e.layerY; 13 if ( e.modifiers & Event.ALT_MASK ) 14 msg += "\nAlt key was down."; 15 if ( e.modifiers & Event.CONTROL_MASK ) 16 msg += "\nControl key was down."; 17 if ( e.modifiers & Event.SHIFT_MASK ) 18 msg += "\nShift key was down."; 19 if ( e.modifiers & Event.META_MASK ) 20 msg += "\nMeta key was down."; 21 alert( msg ); 22 return true; 23 } 24 25 document.onmousedown = myOnMouseDown; 26 27 </SCRIPT> 28 29 </HEAD> 30 31 <BODY BGCOLOR="#FFFFFF"> 32 Click the mouse anywhere in this browser window.<BR> 33 Optionally hold down Ctl, Alt, and/or Shift as you click.<BR> 34 (This experiment requires NN4.0 or later.) 35 </BODY> 36 37 </HTML>