把以下相关代码加到你的网页源代码文件里,别人便不可以复制你的网页
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>
|