每页新/更新图标 [英] New/update favicon per page
问题描述
有些人可能知道那里的脚本,或者知道如何在网站的每个部分更新收藏夹图标.我正在处理的构建的每个部分都有很强的颜色,我认为根据您所处的部分来更新收藏夹图标的颜色可能是一种不错的UI用法.这些图标可能是一个图标数组,但是会强制进行更改,而不仅仅是在每个部分中添加favicon链接rel.
Thought someone might know of a script out there, or know how to update the favicon per section of a site. There's strong colours running through each section of a build I'm working on and I thought it might be a nice UI touch to update the colour of the favicon depending on what section you're on. These could be an array of icons, but something that would force a change, rather than just adding the favicon link rel in each section.
我知道Gmail可以使用未读/新的电子邮件来更新该图标.
I know Gmail can update the favicon with un-read/new emails.
任何帮助/想法都将不胜感激.
Any help/ideas would be appreciated.
干杯, R
推荐答案
使用每页上的rel rel都在正确的轨道上,但是强制进行favicon刷新的技巧是在结尾处添加一个数字图标文件作为不断变化的参数(时间是最安全的选择).
You're on the right track with using the link rel's on every page, but the trick to forcing the favicon refresh is to append a number at the end of the icon file as a parameter that's always changing (time is the safest bet).
使用php的示例:
<?php
echo '<link rel="shortcut icon" href="http://www.yoursite.com/favicon.ico?t=' . time() . '" />';
?>
这样做会使浏览器在每次看到文件时都认为该文件是新文件,从而避免了缓存问题.我希望这会为您指明正确的方向!
Doing this makes the browser think the file is new every time it sees it, thus avoiding the caching issue. I hope this points you in the right direction!
这篇关于每页新/更新图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!