分享好友 资讯首页 资讯分类 切换频道

WordPress文章防复制代码的方法

2025-07-24 03:2030admin001

通过下面的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
dedecms怎么添加会员功能

0评论2025-07-3142

dedecms好操作吗

0评论2025-07-3142

WordPress织梦哪个快

0评论2025-07-3140

dedecms如何修模板

0评论2025-07-3141