WordPress文章防复制代码

Mruei 评论1,2981字数 2518阅读8分23秒阅读模式

通过下面的JS代码,可以有效地防止别人直接复制拷贝你的文章,用frame标签引用你的文章时,会自动跳转到文章正常链接,同时禁止右键菜单。

打开当前主题头部模板header.php找到:<?php wp_head(); ?>将下面代码添加到后面:文章源自Eight Point-http://www.8oio.com/80.html

<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>

 文章源自Eight Point-http://www.8oio.com/80.html

 文章源自Eight Point-http://www.8oio.com/80.html

文章源自Eight Point-http://www.8oio.com/80.html文章源自Eight Point-http://www.8oio.com/80.html
继续阅读
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证