博客文章復(fù)制自動(dòng)加版權(quán)信息

對(duì)于Z-Blog系統(tǒng)來(lái)說(shuō),編輯b_article-single.html這個(gè)模板文件,在適當(dāng)位置加入下面這些代碼即可。

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

對(duì)于WordPress系統(tǒng)來(lái)說(shuō),編輯themes下的模板文件single.php,在適當(dāng)?shù)奈恢眉尤胍韵麓a即可。

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

這樣,當(dāng)別人復(fù)制你文章內(nèi)容的時(shí)候,系統(tǒng)會(huì)自動(dòng)將版權(quán)信息和原文地址加入到復(fù)制內(nèi)容中,這時(shí)別人要是還要手動(dòng)將版權(quán)信息和原文地址刪除,那人品就實(shí)在不怎么樣了。

轉(zhuǎn)載自月光博客