WordPress文章防复制代码的方法

   2025-07-24 admin00130

通过下面的js代码,可以有效地防止别人直接复制拷贝你的文章,用frame标签引用你的文章时,会自动跳转到文章正常链接,同时禁止右键菜单。下面由wordpress教程栏目给大家介绍具体方法。

使用方法一:

打开当前主题头部模板header.php找到:将下面代码添加到后面:

<script>//禁止右键document.oncontextmenu=function(){returnfalse};//禁止图片拖放document.ondragstart=function(){returnfalse};//禁止选择文本document.onselectstart=function(){if(event.srcElement.type!="text"&&event.srcElement.type!="textarea"&&event.srcElement.type!="password")returnfalse;elsereturntrue;};if(window.sidebar){document.onmousedown=function(e){varobj=e.target;if(obj.tagName.toUpperCase()=="INPUT"||obj.tagName.toUpperCase()=="TEXTAREA"||obj.tagName.toUpperCase()=="PASSWORD")returntrue;elsereturnfalse;}};//禁止frame标签引用if(parent.frames.length>0)top.location.replace(document.location);</script>
 
举报收藏 0打赏 0评论 0
 
更多>同类资讯
推荐图文
推荐资讯
点击排行
网站首页  |  关于我们  |  联系方式  |  用户协议  |  隐私政策  |  版权声明  |  网站地图  |  RSS订阅
Powered By DESTOON