WordPress文章防复制代码

EightPoint
EightPoint
管理员
66
文章
0
粉丝
数智软件评论134字数 192阅读0分38秒阅读模式

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

打开当前主题头部模板header.php找到:<?php wp_head(); ?>将下面代码添加到后面:文章源自八点运动-https://www.8oio.com/40.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>

 文章源自八点运动-https://www.8oio.com/40.html

 文章源自八点运动-https://www.8oio.com/40.html 文章源自八点运动-https://www.8oio.com/40.html

 最后更新:2025-2-25
匿名

发表评论

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

拖动滑块以完成验证