`
cary
  • 浏览: 84571 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论

鼠标右键屏蔽

    博客分类:
  • JS
阅读更多
在网上搜了很多文章,试用了下。
结果:只有下面这能用
<script language="JavaScript">
<!--
 
if (window.Event)
  document.captureEvents(Event.MOUSEUP);
 
function nocontextmenu()
{
 event.cancelBubble = true
 event.returnValue = false;
 
 return false;
}
 
function norightclick(e)
{
 if (window.Event)
 {
  if (e.which == 2 || e.which == 3)
   return false;
 }
 else
  if (event.button == 2 || event.button == 3)
  {
   event.cancelBubble = true
   event.returnValue = false;
   return false;
  }
 
}
 
document.oncontextmenu = nocontextmenu;  // for IE5+
document.onmousedown = norightclick;  // for all others
//-->
</script>

其他的什么 oncontextmenu="window.event.returnvalue=false"  <body  oncontextmenu="return false"></body>都不行。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics