您现在的位置:首页 >> 前端 >> 内容

onmousedown事件代码分析

时间:2018/5/9 14:08:28 点击:

  核心提示:function test(){alert(event.x+ +event.y);alert(event.button);}/*右键菜单不显示*/document.oncontextmenu=func...

function test() 

alert(event.x+" "+event.y); 

alert(event.button); 

/*右键菜单不显示*/

document.oncontextmenu=function() 

return false; 

/*document.onmousedown=function() 

if(event.button==1) 

{alert("left")} 

if(event.button==2) 

{alert("right")} 

}*/

document.onkeydown=function() 

alert(event.keyCode); 

</script>

定义和用法

onmousedown 属性在鼠标按钮在元素上按下时触发。

提示:相对于 onmousedown 事件的事件次序(限于鼠标左/中键):

onmousedown onmouseup onclick

相对于 onmousedown 事件的事件次序(限于鼠标右键):

onmousedown onmouseup oncontextmenu

注释:onmousedown 属性不适用以下元素:<base>、<bdo>、<br>、<head>、<html>、<iframe>、<meta>、<param>、<script>、<style> 或 <title>。

Tags:ON NM MO OU 
作者:网络 来源:qq_4140155