前言
有时,自己辛辛苦苦写的文章,却被一些网站自动采集,巴拉过去,甚至都不声明下来源 有时,自己辛辛苦苦写的文章,却被一些网站自动采集,巴拉过去,甚至都不声明下来源
如何在别人复制你网站上文字时,添加上版权声明呢,就像itclanCoder网站, 如何在别人复制你网站上文字时,添加上版权声明呢,就像itClonCoder网站
复制网站上的文字时,当复制文字超过一定的长度时,就携带版权声明,虽然没办法要求复制者必须携带声明,但也算是—种对自己内容额外的保护吧 复制网站上的文字时,当复制文字超过一定的长度时,就携带版权声明,虽然没办法要求复制者必须携带声明,但也算是-种对自己内容额外的保护吧
虽然有点自欺欺人,但设置—点障碍,也没什么的 虽然有点自欺欺人,但设置-点障碍,也没什么的
其实,非常简单,几行代码就可以搞定 其实,非常简单,几行代码就可以搞定
只要在主题文件编辑器“模版函数”(functions.php)里加入以下代码:
//自动添加文章版权
function add_copyright_text() { ?>
<script type='text/javascript'>
function addLink() {
var body_element = document.getElementsByTagName('body')[0];
var selection;
selection = window.getSelection();
var pagelink = " 网址:<a href='"+document.location.href+"'>"+document.location.href+" 出处:兹拉网 <?php the_author(); ?></a>";
var copy_text = selection + pagelink;
var new_div = document.createElement('div');
new_div.style.left='-99999px';
new_div.style.position='absolute';
body_element.appendChild(new_div );
new_div.innerHTML = copy_text ;
selection.selectAllChildren(new_div );
window.setTimeout(function() {
body_element.removeChild(new_div );
},0);
}
document.oncopy = addLink;
</script>
<?php
}
add_action( 'wp_footer', 'add_copyright_text');
没有回复内容