返回到:Prototype – 事件处理
此方法确定与按钮相关的鼠标事件是否与“左”(实际上是主要的)按钮有关。
语法
Event.isLeftClick(event);
返回值
如果按下左键则返回真。
例子
注意– 看起来它在 MSIE 中不起作用。
HTML
x
28
28
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
// Register event 'click' and associated call back.
8
Event.observe(document, 'click', respondToClick);
9
10
// Callback function to handle the event.
11
function respondToClick(event) {
12
var bool = Event.isLeftClick(event);
13
14
if ( bool ) {
15
alert("Left button is pressed...." );
16
}
17
}
18
</script>
19
</head>
20
21
<body>
22
<p id = "note"> Click anywhere to see the result.</p>
23
<p>This example may not work in IE.</p>
24
<p id = "para1">This is paragraph 1</p>
25
<p id = "para2">This is paragraph 2</p>
26
<div id = "division">This is divsion.</div>
27
</body>
28
</html>
返回到:Prototype – 事件处理
阅读剩余 43%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8552.html