WordPress实现禁止右键 禁止复制 不需要插件方法
额外CSS实现:禁止文本选择
Appearance > Cutomize
添加下面代码:
* { -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Safari */ -khtml-user-select: none; /* Konqueror HTML */ -moz-user-select: none; /* Old versions of Firefox */ -ms-user-select: none; /* Internet Explorer/Edge */ user-select: none; /* Non-prefixed version, currently supported by Chrome, Opera and Firefox */ }
JS实现:禁止右键 禁止图片拖放 禁止选择文本 禁止iframe框架调用
Appearance > Theme File Editor
header.php添加下面代码:
<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; } }; // 禁止iframe框架调用 if (parent.frames.length > 0) top.location.replace(document.location); </script>