分享

鼠标特效——禁止复制网页代码

 吉祥如意988 2012-05-05

把以下相关代码加到你的网页源代码文件里,别人便不可以复制你的网页

 

1,禁止鼠标左右键,禁止复制代码:

<SCRIPT language=JavaScript>
 
  document.oncontextmenu=new Function("event.returnValue=false;"); //禁止右键功能,单击右键将无任何反应
 
  document.onselectstart=new Function("event.returnValue=false;"); //禁止先择,也就是无法复制
 
</SCRIPT>

2,鼠标右键自动定向代码:

<HTML>
<HEAD>
<META http-equiv=Content-Type  content=text/html; charset=gb2312>
<TITLE>禁止使用鼠标右键,如果你点了右键页面就自动跳转到相应链接上</TITLE>
</HEAD>
<BODY >

<script language="Javascript">

 

if (navigator.appName.indexOf("Internet Explorer") != -1) 

 document.onmousedown = noSourceExplorer;

 

function noSourceExplorer()

{

 if (event.button == 2 | event.button == 3)

 {

  alert("禁止右键...去主页看看!");

  location.replace("http:///");

 }

}

</script>

 


</BODY></HTML>

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>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多