网页防复制代码

来源:互联网 发布:办公室网络架构方案 编辑:程序博客网 时间:2024/05/01 22:11

为保护作者的著作版权,有时需要在网页添加禁止复制的功能。只需在<head>与</head>之间添加以下代码就可达到目的:
<SCRIPT language=JavaScript>
function click() {
alert('谢绝复制!请谅解!')}
function clickl(){
if (event.button==2){alert('谢绝复制!请谅解!')}}
function ctrlkeydown(){
if (event.ctrlkey) {alert('不当的拷贝将损坏您的爱机!')}}
document.onkeydown=ctrlkeydown;
document.onselectstart=click;
document.onmousedown=clickl;
</script>

以上这个防复制的方法好是好,不过道高一尺魔高一丈。以下就是魔高一丈的表现:打开浏览器,工具→Internet选项(0)→安全→自定义级别,将“脚本”的三个设置项均设为“禁用”,再沿路确定回去,刷新网页,OK!不过这样设置以后网页的很多特效就看不到了,所以拷贝好所需内容后最好还是重新设置一下那三个脚本为启用状态。

2.<body leftmargin="2" 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()">
<noscript><iframe src="/blog/*>";</iframe></noscript>
代码使用说明:
1. oncontextmenu="window.event.returnvalue=false" //将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> //可用于Table
-----------------------------------------------------------
2. <body onselectstart="return false"> //取消选取、防止复制
-----------------------------------------------------------
3. onpaste="return false" //不准粘贴
-----------------------------------------------------------
4. oncopy="return false;" oncut="return false;" // 防止复制
-----------------------------------------------------------
5. //防止被人frame
<SCRIPT LANGUAGE=javascript><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
-----------------------------------------------------------
6. <noscript><iframe src="/blog/*.html>";</iframe></noscript> //网页将不能被另存为
-----------------------------------------------------------
7. //改变连接是状态栏的显示内容
〈a href="http://www.yt12333.cn" onMo ... ;window.status='输入连接状态栏显示内容’;return true">
-----------------------------------------------------------
8. //禁止网页中目标对象被下载(如图片)
下面的代码将帮助你禁止网页中目标对象被下载:
<a href="javascript:void(0)" onMouseDown="alert('对不起!图片不能下载!')"></a>
-----------------------------------------------------------
9. //页面禁止刷新完全
最好在pop出来的窗口里用,没工具栏的
<body onkeydown="KeyDown()" onbeforeunload="location=location"
oncontextmenu="event.returnValue=false">
<script language="Javascript"><!--
function KeyDown(){
if ((window.event.altKey)&&
((window.event.keyCode==37)||
(window.event.keyCode==39))){ alert("请访问我的主页");
event.returnValue=false;
}
if ((event.keyCode==8)|| (event.keyCode==116)){ //屏蔽 F5 刷新键
event.keyCode=0;
event.returnValue=false;
}
if ((event.ctrlKey)&&(event.keyCode==78)){ //屏蔽 Ctrl+n
event.returnValue=false;
}
if ((event.shiftKey)&&(event.keyCode==121)){ //屏蔽 shift+F10
event.returnValue=false;
}
}
</script>
</body>

原创粉丝点击