通过下面的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>