WordPress 复制文章自动加版权信息
复制网站文字跳出版权信息弹窗,就像微言心语里的一样,效果如下
只需要在fcuntion.php里添加以下代码即可实现
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | //复制弹出版权信息 function add_copyright_text() { ?> <script type='text/javascript'> function addLink() { var body_element = document.getElementsByTagName('body')[0]; var selection; selection = window.getSelection(); var pagelink = "<br /><br /> 转载请注明来源: <a href='"+document.location.href+"'>"+document.location.href+"</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 } |