php禁止复制网页内容功能

来源:互联网 发布:软件开发流程文档 编辑:程序博客网 时间:2024/05/21 11:24
1、在不想被复制内容的php页面中添加引用<script src="../nocopy.js" type="text/javascript"></script>

2、同时在网站文件夹中放入nocopy.js文件,当前../nocopy.js表示nocopy.js文件在根文件夹中

3、nocopy.js中的文件内容是:

var omitformtags=["input", "textarea", "select"]
omitformtags=omitformtags.join("|")

function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}

function reEnable(){
return true
}

if (typeof document.onselectstart!="undefined")
document.onselectstart=new Function ("return false")
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
原创粉丝点击