醬茄 jiangqie.com
多人問wordPress/ target=_blank class=infotextkey>WordPress文章怎么防止別人復(fù)制,今天醬茄小編把代碼分享給大家,通過下面的JS代碼即可有效的防止別人直接復(fù)制你的文章,用frame標(biāo)簽引用你的文章時,會自動跳轉(zhuǎn)到文章正常鏈接,同時禁止右鍵菜單。
使用方法:
打開當(dāng)前主題頭部模板header.php找到:<!--?php wp_head(); ?-->將下面代碼添加到后面:
// 醬茄 jiangqie.com 禁止右鍵
document.oncontextmenu = function() {
return false
};
// 醬茄 jiangqie.com 禁止圖片拖放
document.ondragstart = function() {
return false
};
// 醬茄 jiangqie.com 禁止選擇文本
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;
}
};
// 醬茄 jiangqie.com 禁止frame標(biāo)簽引用
if (parent.frames.length > 0) top.location.replace(document.location);
當(dāng)然上面的方法,也只是忽悠一下小白,瀏覽器禁用JAVAScript后,將失去效果。
文章來自: https://www.jiangqie.com/jc/6540.html






