wordpress复制文章加一段话

  • A+
所属分类:博客日记

有时候为了避免别的网站无版权复制就发出,我们难免会要用到一些手段,就…比如是这个。

将以下代码在<head></head>之间加载即可:

  1. <script ="text/javascript">function addLink() {
  2.     var selection = window.getSelection();
  3.     pagelink = ". 原文出自[麦屯博客] 转载请保留原文链接:" + document.location.href;
  4.     copytext = selection + pagelink;
  5.     newdiv = document.createElement('div');
  6.     newdiv.style.position = 'absolute';
  7.     newdiv.style.left = '-99999px';
  8.     document.body.appendChild(newdiv);
  9.     newdiv.innerHTML = copytext;
  10.     selection.selectAllChildren(newdiv);
  11.     window.setTimeout(function () {
  12.         document.body.removeChild(newdiv);
  13.     }, 100);
  14. }
  15. document.oncopy = addLink;</script>
图片引用自网络