给你的浏览器标题栏加上小图标

方法很简单:用JS向HTML中<head></head>添加一行类似这样的代码:

<link rel="shortcut icon" type="image/x-icon" href="images/favicon.png" /> 

但是我们不可能改动到博客园中的HTML文档的,幸好cnblog的后台管理允许我们CSS定制自己的样式和添加“页首/脚Html代码”。于是我们可以在后台管理-设置中的“页首Html代码”框用JS写入代码:

 <script type="text/javascript">
   var head = document.getElementsByTagName('head')[0],
   linkTag = document.createElement('link');   linkTag.href="http://images.cnblogs.com/cnblogs_com/hewenwei/535253/o_favicon.png";
   linkTag.setAttribute('rel','shortcut icon');
   linkTag.setAttribute('type','image/x-icon');
   head.appendChild(linkTag); 
</script>

这里,我的 o_favicon.png 已经上传到博客园中的相册中,再作此用的。

转载于:https://www.cnblogs.com/hewenwei/p/3971777.html

原文地址:https://www.cnblogs.com/yellowhh/p/12034766.html