`

屏蔽鼠标右键的JS代码,兼容IE6 IE7 IE8 Firefox Chrome

 
阅读更多
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 

<body>

<!-- 屏蔽网页右鍵,适用于IE6,IE7,IE8,FireFox,谷歌Chrome浏览器 开始-->

<script type="text/javascript">
 function clickIE4(){
         if (event.button==2){
                 return false;
         }
 }
  
 function clickNS4(e){
         if (document.layers||document.getElementById&&!document.all){
                 if (e.which==2||e.which==3){
                         return false;
                 }
         }
 }
  
 function OnDeny(){
         if(event.ctrlKey || event.keyCode==78 && event.ctrlKey || event.altKey || event.altKey && event.keyCode==115){
                 return false;
         }
 }
  
 if (document.layers){
         document.captureEvents(Event.MOUSEDOWN);
         document.onmousedown=clickNS4;
         document.onkeydown=OnDeny();
 }else if (document.all&&!document.getElementById){
         document.onmousedown=clickIE4;
         document.onkeydown=OnDeny();
 }
  
 document.oncontextmenu=new Function("return false");
 </script>
 <!--屏蔽网页右鍵,适用于 IE6,IE7,IE8,FireFox,谷歌Chrome浏览器 结束-->
 </body> 
</html>

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics