wordpress如何防止文章复制(附代码)

2025年02月15日 建站教程

wordpress如何防止文章内容被复制,下面web建站小编给大家详细介绍一下实现代码!

找到header.php​模板,在<?php wp_head(); ?>​中新增以下代码:

<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;
  }
};

// 禁止frame标签引用
if (parent.frames.length > 0) top.location.replace(document.location);
</script>

本文链接:http://so.lmcjl.com/news/23200/

展开阅读全文
上一篇:WSL ip地址 下一篇:房屋装修合同范文
相关内容