且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

根据查询的资料,得到两种比较好的方法

更新时间:2022-09-13 20:19:29

1)添加javascript:
<script language="javascript">
<!--

<!--
function document.oncontextmenu() 

return false; 

-->
-->
</script>
  在要屏蔽的页面的body中添加:
   <body  oncontextmenu= "nocontextmenu()">

2)添加Javascript,到要屏蔽的页面
<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>   

本文转自kenty博客园博客,原文链接http://www.cnblogs.com/kentyshang/archive/2007/04/02/697018.html如需转载请自行联系原作者


kenty