现在的位置: 首页 > 综合 > 正文

js 捕捉右键事件

2013年06月21日 ⁄ 综合 ⁄ 共 422字 ⁄ 字号 评论关闭

88888888888888888888888888

上面是效果,下面代码

<html>  
<script type="text/javascript">  
 <!--  
    document.onmousedown = function(e){  
        var e = e || window.event  
        alert("e"+e.button);  
        if(e.button == "2"){  
            alert("执行右键代码");  
        }  
    }  
 //-->  
 function right()  
 {  
          
        var e=window.event;  
        alert(e.button);  
        if(e.button=="0"){  
            alert("左键");  
        }else{  
            alert("右键");  
        }  
 }  
 </script>  
  
  
  
<table border=1>  
<tr id=test name=test height=200  onmousedown="right()" ><td>88888888888888888888888888</td></tr>  
</table>  
  
</html>  


抱歉!评论已关闭.