站内搜索:
首页 >> 前端 >> 内容
onmousedown事件代码分析

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

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>。

  • 上一篇:MVC后台数据赋值给前端JS对象详解
  • 下一篇:IO多路复用之select函数实例详解
  • 返回顶部