右键复制时显示提示语
后台—>外观—>编辑,找到“footer.php” 文件,然后在</body>标签之前添加以下代码:
<html>
<head><title></title><meta http-equiv="Content-Type" cont
ent="text/html; charset=utf-8" /></head>
<script>
function stop(){
alert('鄙视盗版,尊重版权,自己想办法复制 凸(`0´)凸!');
return false;
}
document.oncontextmenu=stop;
</script>
<body onselectstart="return false" onpaste="return false" oncop
y="return false;"
oncut="return false;" >
</body>
</html>
还可以添加防止拖拽图像、防止iframe等功能
打开当前主题头部模板header.php找到:<?php wp_head(); ?>将下面代码添加到后面:
<script>
// 禁止右键
document.oncontextmenu = function() {
return false
};
// 禁止图片拖放
document.ondragstart = function() {
return false
};
// 禁止选择文本
document.onselectstart = function() {
if (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password") return false;
else return true;
};
if (window.sidebar) {
document.onmousedown = function(e) {
var obj = e.target;
if (obj.tagName.toUpperCase() == "INPUT" || obj.tagName.toUpperCase() == "TEXTAREA" || obj.tagName.toUpperCase() == "PASSWORD") return true;
else return false;
}
};
// 禁止frame标签引用
if (parent.frames.length > 0) top.location.replace(document.location);
</script>
上面的方法查看源代码时有些乱,可以在当前主题目录新建一个名称为copyright.js文件,将下面代码添加进去:
// 禁止右键
document.oncontextmenu = function() {
return false
};
// 禁止图片拖放
document.ondragstart = function() {
return false
};
// 禁止选择文本
document.onselectstart = function() {
if (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password") return false;
else return true;
};
if (window.sidebar) {
document.onmousedown = function(e) {
var obj = e.target;
if (obj.tagName.toUpperCase() == "INPUT" || obj.tagName.toUpperCase() == "TEXTAREA" || obj.tagName.toUpperCase() == "PASSWORD") return true;
else return false;
}
};
// 禁止frame标签引用
if (parent.frames.length > 0) top.location.replace(document.location);
把下面代码放到footer.php里即可。
<script type="text/Javascript">
<!--
document.oncontextmenu=function(e){return false;};
document.onselectstart=function(e){return false;};
//-->
</script>
<style>
body{
-moz-user-select:none;
}
</style>
<SCRIPT LANGUAGE=javascript><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>
<noscript><iframe src=*.html></iframe></noscript>
Comments | NOTHING