博客文章复制自动加版权信息

对于Z-Blog系统来说,编辑b_article-single.html这个模板文件,在适当位置加入下面这些代码即可。

  1. <script type="text/javascript">
  2. document.body.oncopy=function(){
  3.  event.returnValue=false;
  4.  var t=document.selection.createRange().text;
  5.  var s="本文来源于<#ZC_BLOG_TITLE#> <#ZC_BLOG_HOST#> , 原文地址:<#article/url#> ";
  6.  clipboardData.setData('Text','\r\n'+t+'\r\n'+s+'\r\n\r\n\r\n');
  7. }
  8. </script>

对于WordPress系统来说,编辑themes下的模板文件single.php,在适当的位置加入以下代码即可。

  1. <script type="text/javascript">
  2. document.body.oncopy=function(){
  3.  event.returnValue=false;
  4.  var t=document.selection.createRange().text;
  5.  var s="本文来源于<?php bloginfo('name'); ?> <?php echo get_settings('home'); ?> , 原文地址: <?php the_permalink() ?> ";
  6.  clipboardData.setData('Text','\r\n'+t+'\r\n'+s+'\r\n');
  7. }
  8. </script>

这样,当别人复制你文章内容的时候,系统会自动将版权信息和原文地址加入到复制内容中,这时别人要是还要手动将版权信息和原文地址删除,那人品就实在不怎么样了。

转载自月光博客 [ http://www.williamlong.info/ ]

相似日志:

发表评论