在网页代码中屏蔽右键

1.弹出提示框“不许你用右键”的代码:
<script language="javascript"> document.onmousedown=function(){ if(event.button==2)alert("不许你用右键,哈哈");}</script>

2.点右键没用动作的代码:
<script language="javascript"> document.oncontextmenu=function(){return false;}</script>

3.<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>

4.<body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' onselect='document.selection.empty()' oncopy='document.selection.empty()' onbeforecopy='return false' onmouseup='document.selection.empty()'>
</body>
<noscript>
<iframe src="*"></iframe></IFRAME>
</noscript>


另一种方法:
在网页中调用以下js文件:

引用内容
<!--#include file="mouse.js" -->
<script language="javascript">
function click(e) {
if (document.all) {
  if (event.button==1||event.button==2||event.button==3) {
   oncontextmenu='return false';
  }
}
if (document.layers) {
  if (e.which == 3) {
   on

CopyRight©2007-2009 21805.com | 苏ICP备07023309号 | | 收藏本站
本站只是私人BLOG小站.希望高手手下留情!谢绝一切恐怖活动!My love is dancing all around you! - 爱要伴你舞-成长的快乐 Since 2007.06.08