home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap17 / dun17_8.txt < prev    next >
Encoding:
Text File  |  1997-12-18  |  1.2 KB  |  46 lines

  1. <HTML>
  2. <HEAD>
  3.   <TITLE>Displaying Context-Sensitive Menus Using Mouse Position</TITLE>
  4.   <STYLE TYPE="text/css">
  5.     .contextMenu  { background-color: #CCCCCC; font-size: 9pt;
  6.                     font-family: ms sans serif, helvetica, sans-serif;
  7.                     line-height: 1.5em; padding: 10px;
  8.                     border-style: solid; border-width: 1;
  9.                     border-color: white; }
  10.   </STYLE>
  11.  
  12.   <SCRIPT>
  13.     function showDefaultMenu(event)
  14.     {
  15.       if (event.modifiers & Event.CONTROL_MASK)
  16.       {
  17.         document.defaultMenu.left = event.x;
  18.         document.defaultMenu.top = event.y;
  19.         document.defaultMenu.visibility = "show";
  20.       }
  21.     }
  22.  
  23.     function hideDefaultMenu(event)
  24.     {
  25.       document.defaultMenu.visibility = "hide";
  26.     }
  27.  
  28.     document.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
  29.     document.onmousedown = showDefaultMenu;
  30.     document.onmouseup = hideDefaultMenu;
  31.   </SCRIPT>
  32. </HEAD>
  33.  
  34. <BODY>
  35. <H2>Displaying Context-Sensitive Menus Using Mouse Position</H2>
  36.  
  37. <DIV ID=defaultMenu CLASS=contextMenu
  38.      STYLE="position: absolute; visibility: hide; width: 100; ">
  39.   Cut<BR>
  40.   Copy<BR>
  41.   Paste
  42. </DIV>
  43.  
  44. </BODY>
  45. </HTML>
  46.