根据URL自动获取网页的favicon.ico图标,使你在网页开发中变的更方便。
要获取一个favicon.ico 你可以链接到...
http://ico.ylsnuha.com/[URL]
注意网址中包含协议(http或https)。 例如...
http://ico.ylsnuha.com/http://www.google.com
以下是一个标准的<img> 标签...
<img src="http://ico.ylsnuha.com/http://www.google.com" alt="Google" width="16" height="16" />
如果指定的域名无法获取图标,那可以指定一个默认图标...
http://ico.ylsnuha.com/http://www.google.com?defaulticon=http://en.wikipedia.org/favicon.ico
也可以定义defaulticon为以下4种:
none: 没有默认的图标将被退回1pxgif: 1px x 1px透明的GIFlightpng: 灰色'世界'的图标bluepng: 浅蓝'世界'图标您可以从缓存中调用由一个图标/decache/?domain=[domain]例如:/decache/?domain=http://www.google.com.
你可以使用JS为连接动态加载图标,这用不用编辑原始连接的代码
如果你没有载入JQuery库的话请先载入,已经有的跳过。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
插入一下JS,注意 #links a请根据自己的连接表标签做修改
<script type="text/javascript">
jQuery(document).ready(function($){
$("#links a").each(function(){
$(this).prepend("<img src=http://ico.ylsnuha.com/"+this.href.replace(/^(http:\/\/[^\/]+).*$/,'$1')+" style='float:left;padding:5px;width:16px;height:16px;'>")})});
</script>
注意:被墙网站请使用 http://ico.ylsnuha.com/https://www.xxx.com 安全连接,负责会被GFW关键字过滤功能屏蔽掉。
1000 more examples on the test page.
Updated every minute or so