本文是記錄favicon.ico在不同瀏覽器下的顯示問題:
創建網頁文件index.html
<html> <head> <title>icon test</title> <link rel="icon" href="Images/test.ico" type="image/x-icon" /> <link rel="shortcut icon" href="Images/test.ico" type="image/x-icon" /> </head> <body> body part </body> </html>
打開網頁localhost:8080/index.html
360瀏覽器在瀏覽網頁的時候,會忽略端口:
firefox請求的是:link 的href所對應的圖標。
搜狗瀏覽器等:請求的是http://localhost:8080/favicon.ico.
360瀏覽器等:請求的是http://localhost/favicon.ico,
也就是不管你請求的是http://host/home.html,還是http://host:8080/home.html,還是http://host/test/index.html.
它請求的都是http://host/favicon.ico.
如果網站favicon.ico 不起作用,或者是想要讓favicon.ico 的兼容性更好,解決方法:
1:檢查網站根目錄下面的favicon.ico,也就是:http://host/favicon.ico.,而不是http://host/some/favicon.ico.
2:確保<link rel="icon" href="http://host/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://host/favicon.ico" type="image/x-icon" />
3:如果你的網站帶端口,或者是測試版本的話,那么尤其要注意360等瀏覽器,它們在請求favicon.ico 的時候會忽略端口號的。
原文內容:http://blog.csdn.net/zhizaibide1987/article/details/42001955