这是新版PHPWind论坛中的一个功能,在别人复制网站内容的时候可以自动加上版权信息。月光做了些修改,在Z-blog和Wordpress博客程序中实现了这一功能,我在月光的基础上也改动了一下。
对于Wordpress博客程序,编辑模版的single.php文件,在合适的位置加入下面的代码:
var postName=getPostName();
function getPostName(){ var str = document.location.pathname; return str.substring(str.lastIndexOf("sorryle.com/")+1,str.lastIndexOf("/")); }
document.body.oncopy=function(){ event.returnValue=false; var t=document.selection.createRange().text; var s="本文来源于sorryle's blog: http://sorryle.com/ , 原文地址:http://sorryle.com"+postName+"/"; clipboardData.setData('Text','\r\n'+t+'\r\n'+s+'\r\n'); }
文中的“sorryle.com”改成你自己的博客地址,函数getPostName()是读取“http://sorryle.com/auto-copyright/”中的“auto-copyright”来实现后面的显示原文地址,具体情况可根据你自己博客的Permalink设置来修改。
2 Responses
yangtx
January 9th, 2008 at 8:58 pm
1先收下了,我现在不打算用,毕竟文章不够力度。
sorryle
January 9th, 2008 at 11:35 pm
2我的文章现在应该也没有人转载,不过先预防:)
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Popular Posts