home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 August / INTERNET94.ISO / pc / software / windows / building / webmenu_studio / wmstud01.cab / _455974BF5B504071AF426CBF25D6B31F < prev    next >
Encoding:
Text File  |  2002-03-14  |  3.6 KB  |  115 lines

  1. <html>
  2. <head>
  3.     <title>COALESYS, Inc.</title>
  4.  
  5.     <script language="JavaScript" type="text/javascript">
  6.     
  7.     // Function which shows the Context Menu by calling
  8.     // cswmShow and passing in coordinates.
  9.     function ShowContextMenu(e)
  10.     {
  11.         // Quick and Dirty IE NN 6.1 Detection
  12.         if(document.oncontextmenu)
  13.         {
  14.             // IE
  15.             if(document.all)
  16.                 cswmShow('File', '', 'above', event.x + document.body.scrollLeft, event.y + document.body.scrollTop, 1);
  17.             // NN 6.1
  18.             else
  19.                 cswmShow('File', '', 'above', e.pageX, e.pageY, 1);
  20.             return false;
  21.         }
  22.         // Quick and Dirty NN4 Detection
  23.         else if (document.layers)
  24.         {
  25.             if (e.which == 3)
  26.             {
  27.                 cswmShow('File', '', 'above', e.pageX, e.pageY, 1);
  28.                 return false;
  29.             }
  30.         }
  31.         // Quick and Dirty NN6.0 Detection
  32.         else if (document.getElementById)
  33.         {
  34.             if (e.which == 3)
  35.             {
  36.                 e.preventDefault();
  37.                 cswmShow('File', '', 'above', e.pageX, e.pageY, 1);
  38.                 return false;
  39.             }
  40.         }
  41.     }
  42.     
  43.     // capture event for context menu
  44.     // Quick and Dirty NN4 Detection
  45.     if(document.layers)
  46.     {
  47.         document.captureEvents(Event.MOUSEDOWN);
  48.         document.onmousedown=ShowContextMenu;
  49.     }
  50.     // Quick and Dirty IE Detection
  51.     else if(typeof document.oncontextmenu == "object")
  52.     {
  53.         document.oncontextmenu = ShowContextMenu;
  54.     }
  55.     // Quick and Dirty NN6 Detection
  56.     else if(!document.all && document.getElementById)
  57.     {
  58.         //  NN 6.1 requires different handling than 6.0
  59.         if(parseFloat(navigator.vendorSub)>=6.1)
  60.             document.oncontextmenu=ShowContextMenu;
  61.         else
  62.             document.onmouseup=ShowContextMenu;
  63.     }
  64.     </script>
  65.  
  66. </head>
  67.  
  68. <body onResize="cswmRefresh()" scroll="auto" link="red" alink="red" vlink="red" bgcolor="#ffffff" leftmargin=10 topmargin=10 marginheight=10 marginwidth=10>
  69.  
  70. <script language="JavaScript" type="text/javascript" src="./includes/loader.js"></script>
  71.  
  72.  
  73. <br>
  74. <br>
  75. <table width="100%" border=0 cellpadding=5 cellspacing=5>
  76.     <tr>
  77.         <td colspan=2>
  78.             <p><b>About the Sample:</b></td>
  79.     </tr>
  80.     <tr>
  81.         <td width=10></td>
  82.         <td>
  83.             <p>
  84.                 This sample demonstrates how you can create your own client-side wrapper for calling <b>cswmShow()</b>.  In this case, the wrapper enables right-click "Context Menu" ability in IE 5, NN4 & NN6.  The menu used is the NetMenu WMS sample, which is explained in detail elsewhere.
  85.             <p>
  86.                 By setting up the page to capture a right click event in the document, we are able to call our own client-side function called ShowContextMenu().
  87.             <p>
  88.                 Inside ShowContextMenu() a call is made to <b>cswmShow()</b>, passing in the menu Group <b>ID</b> that we would like to show (in this case, "File"), the direction the menu will try to appear from the determinded coordinates (in this case, "above"), the X and Y coordinates of the mouse pointer discovered by examining the browser's event object and a flag which instructs <b>cswmShow()</b> to use absolute positioning instead of relative.
  89.             
  90.         </td>
  91.     </tr>
  92.     <tr>
  93.         <td colspan=2>
  94.             <p><b>View the Code:</b></td>
  95.     </tr>
  96.     <tr>
  97.         <td width=10></td>
  98.         <td>
  99.             <p>
  100.                 The code for this sample is available in the product installation directory:
  101.                 <ul>
  102.                     <li><b>netmenu.wms</b> - The WebMenu Studio project file.
  103.                     <li><b>netmenu.wmt</b> - The Preview template used by the Studio's Live Preview window.
  104.                     <li><b>default.htm (this file)</b> - Uses the WebMenu compiled output and discusses the sample.
  105.                     <li><b>./includes/*</b> - The WebMenu output compiled from the studio application.
  106.                     <li><b>./images/*</b> - The images used in this sample.
  107.                 </ul>
  108.  
  109.         </td>
  110.     </tr>
  111. </table>
  112.  
  113. </body>
  114. </html>
  115.