BlogEngine.NET 1.3.1.0 版本有 E-mail | Kick it! | DZone it! | del.icio.us 等书签链接,
近日发现腾讯公司的QQ书签也不错,我就想给BlogEngine.NET添加一个链接。
根据腾讯的帮助文件:http://shuqian.qq.com/help/zh_CN/tools.html#p5
提供一段代码即可实现这一个功能:
<a href="javascript:window.open('http://shuqian.qq.com/post?from=3&title='+encodeURIComponent(document.title)+'&uri='+encodeURIComponent(document.location.href)+'&jumpback=2&noui=1','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"
style="text-decoration:none;color:#155da5;display:block;background:url('http://shuqian.qq.com/img/add.gif') no-repeat 0px 0px;height:23px;width:116px;padding:2px 2px 0px 20px;font-size:12px;">
收藏到QQ书签</a>
这段代码添加到哪里呢?
答:添加到“/themes/你的主题/PostView.ascx”页面里面。打开PostView.ascx你能发现“E-mail | Kick it! | DZone it! | del.icio.us 等书签链接”也在那里,放置在这些链接之前就可以了。
但是使用后你会发现几个问题:
第一,显示问题,由于使用display:block;样式,使得后面的链接分行了。解决办法就是去掉style中间的display:block;
第二,href中间的链接使用的是document.title,document.location.href也就是说,添加的是当前的页面,如果对应的页面是一个博客文章的列表页面,那这个链接就是错误的。解决办法,当时修改一下改成如下就可以了:
<a rel="nofollow"
href="javascript:window.open('http://shuqian.qq.com/post?from=3&title=<%=Server.UrlEncode(Post.Title) %>&uri=<%=Server.UrlEncode(Post.PermaLink.ToString()) %>&jumpback=2&noui=1','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"
style="text-decoration:none;color:#155da5; background:url('http://shuqian.qq.com/img/add.gif') no-repeat 0px 0px;height:23px;width:116px;padding:2px 2px 0px 20px;font-size:12px;"
>收藏到QQ书签</a> |
最终显示效果: