博客版权声明
写在前面
当你复制粘贴别人写的博文的时候你会发现有版权声明的信息, 效果如下
实现
找到next主题下的next\layout\_layout.swig, 在<body/>后添加如下代码
<script type='text/javascript'>
function addLink() {
var body_element = document.getElementsByTagName('body')[0];
var selection;
if(window.getSelection){//DOM,FF,Webkit,Chrome,IE10
selection = window.getSelection();
}else if(document.getSelection){//IE10
selection= document.getSelection();
}else if(document.selection){//IE6+10-
selection= document.selection.createRange().text;
}else{
selection= "";
}
var pagelink = "<br /><br/ ><br />" +
"著作权归作者所有<br />" +
"商业转载请联系作者获得授权,非商业转载请注明出处 <br />" +
"作者:zfl <br />" +
"链接:https://zhangfuli.github.io/<br /><br /><br />";
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.body.oncopy = addLink;
</script>
博客版权声明
https://zhangfuli.github.io/2018/06/04/博客版权声明/