JavaScript Reference/Javascript Properties/button

Материал из Web эксперт
Версия от 08:22, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"button" Example

    
<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>
<div style="width:200; 
            height:200; 
            background-color:blue;" 
     onmousedown="function1();">
Press on mouse while on top of this blue box.
</div>
</body>
</html>



"button" is applied to

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



"button" Possible Values

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.



"button" Syntax and Note

Note:
Read and write property. 
Specifies the mouse button pressed by the user. 
    
Syntax:
    
window.event.button = value