网站运营逃脱不了内容被复制,我们只能尽量避免这种情况发生。可以尝试在别人复制内容时增加一段个人的版权信息,以此来劝诫吧。
下面两组代码都能实现自动添加版权信息。两个代码的效果是一致的,可以先任意选择一个。
代码添加在WordPress主题中的header.php文件中,位于上面即可
代码一:
<script ="text/javascript">function addLink() {
var selection = window.getSelection();
pagelink = ". 本文来自: 尘心网(https://cx9.cn),转载请保留原文链接: " + document.location.href;
copytext = selection + pagelink;
newdiv = document.createElement('div');
newdiv.style.position = 'absolute';
newdiv.style.left = '-99999px';
document.body.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function () {
document.body.removeChild(newdiv);
}, 100);
}
document.oncopy = addLink;</script>
代码二:
<script ="text/javascript">function addLink() {
var body_element = document.body;
var selection;
selection = window.getSelection();
if (window.clipboardData) { // Internet Explorer
var pagelink ="\r\n\r\n 本文来自: 尘心网(https://cx9.cn),转载请保留原文链接: "+document.location.href+"";
var copytext = selection + pagelink;
window.clipboardData.setData ("Text", copytext);
return false;
} else {
var pagelink = " 本文来自: 尘心网(https://cx9.cn),转载请保留原文链接: "+document.location.href+"";
var copytext = selection + pagelink;
var newdiv = document.createElement('div');
newdiv.style.position='absolute';
newdiv.style.left='-99999px';
body_element.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function() {
body_element.removeChild(newdiv);
},0);
}
}
document.oncopy = addLink;</script>
THE END
喜欢就支持一下吧