JavaScript Reference/Javascript Properties/button

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

"button" Example

   <source lang="javascript">
   

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

   function function1() {
       var m = window.event.button;
       if (m == 1) { 
           alert("The left button has been pressed"); 
       } else if (m == 2) { 
           alert("The right button has been pressed"); 
       }
   }

</script>

Press on mouse while on top of this blue box.

</body> </html>


     </source>
   
  


"button" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |event | +----------------+--------------------------------------------------------------+

     </source>
   
  


"button" Possible Values

   <source lang="javascript">

Possible Values 0 the default; no button is pressed, 1 left button is pressed, 2 right button is pressed, 3 left and right buttons are pressed, 4 middle button is pressed, 5 left and middle buttons are pressed, 6 right and middle buttons are pressed, 7 all three buttons are pressed.


     </source>
   
  


"button" Syntax and Note

   <source lang="javascript">

Note: Read and write property. Specifies the mouse button pressed by the user.

Syntax:

window.event.button = value


     </source>