美化 Z-Blog 友情链接 调用Favicon图标

时间:2019-08-29   阅读:479

前面介绍了《Typecho 友情链接获取Favicon图标》,在教程里面博客吧也说过JS这玩意现在基本是通用的,所以在Typecho可以使用JS实现的东西,在Z-Blog博客也是可以实现,只是由于Z-Blog的主题模板构造有点点不同,要给多个模板添加代码,考虑到新手可能会有点困难,所以博客吧在此特别介绍下。

Z-Blog 博客友情链接调用Favicon图标的方法:

  1. 由于Z-Blog 博客的顶部并没有像WordPress或Typecho一样,用header.php文件实现,而是与index、sidebar、footer连在一起,所以要在default.html、single.htm、catalog.html、tags.html、gestbook.html、search.html模板中的<head>和</head>之间添加加载jQuery库的JS代码:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
  2. 然后再在default.html、single.htm、catalog.html、tags.html、gestbook.html、search.html模板中的jQuery库JS代码之后添加以下代码:

    <script type="text/javascript">///友情链接图标faviconjQuery(document).ready(function($){ $(".blogroll a").each(function(e){
    	$(this).prepend("<img src=http://www.google.com/s2/favicons?domain="+this.href.replace(/^(http:\/\/[^\/]+).*$/, '$1').replace( 'http://', '' )+" style=float:left;padding:5px;>");}); });</script>
  3. 保存文件后,重建文件,刷新首页即可。
     美化 Z-Blog 友情链接 调用Favicon图标 文章

提示:如果只有首页显示友情链接,除了default.html文件外,其它文件不用添加相关JS代码。

上一篇:Z-Blog 博客主机关键字过滤会导致的问题

下一篇:实现 Z-Blog 博客评论分页显示效果的方法

网友评论