一、弹窗提示
Javascript 代码实现
将代码添加到 html 中即可,比如添加到模板的 footer.php、header.php。
<script type="text/javascript">
document.body.oncopy=function(){alert('复制成功!本站文章皆为原创,未经允许禁止转载或抄袭,若要转载请务必保留原文链接谢谢合作!');}
</script>
二、添加文章版权说明
复制文章内容后不会有任何提示,但是粘贴时会自动把文章链接加到复制的内容后面。
这段js代码我是放在post.php的文章内页php
<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+"</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>
评论 (0)