JavaScript Reference/Event Handlers Reference/onContextMenu

Материал из Web эксперт
Перейти к: навигация, поиск

"onContextMenu" Example

   <source lang="javascript">
   

<html> <head> <script language="JavaScript">

   function function2() {
       alert("This image is copyrighted") 
   }

</script> </head> <body oncontextmenu="function2()">

Right click in the image.

   <img oncontextmenu="function2()" 
        src="http://www.wbex.ru/style/logo.png" 
        alt="" 
        width="99" 
        height="76">

</body> </html> If you want to prevent the user from opening the context menu, add the following code to the <body> element above: oncontextmenu="function2(); return false;"


     </source>
   
  


"onContextMenu" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <address> | | |<applet> <area> | | | |

| |
|

| |<body> <button> |

| |
|

| | | | |<custom>

| | | <dir> |

| |
|

| |document

| | | <embed> | | |<fieldset> | | |<form> <hn> |

| |
|

| |<img> <input type="button"> | | |<input type="checkbox"> <input type="file"> | | |<inputtype="image"> <input type="password"> | | |<input type="radio"> <input type="reset"> | | |<input type="submit"> <input type="text"> | | | <label> |

| |<legend>
  • | | |<listing> <marquee> | | |<menu> <nobr> | | |

      | | |

                                                           |
      |                |                                                     |
      |                |                          <select>                      |
      |                |                                                 |
      |                |                                              |
      |                |                                                    |
      |                |                         <tbody>                       |
      |                |                          |
      |                |                                                       |
      |                |
        | | |<xmp> | +----------------+--------------------------------------------------------------+ </source>

        "onContextMenu" Properties

        <source lang="javascript"> +----------------+--------------------------------------------------------------+ | Properties |altKey altLeft | | |cancelBubble clientX | | |clientY ctrlKey | | |ctrlLeft offsetX | | |offsetY returnValue | | |screenX screenY | | |shiftKey shiftLeft | | |srcElement type | | |x y | +----------------+--------------------------------------------------------------+

        </source>



        "onContextMenu" Syntax and Note

        <source lang="javascript"> Note:

        This event fires when the user opens the context menu by clicking the right mouse button.


        </source>

      <textarea> | | |<tfoot> | | |<thead>