Html 在网页源中找不到图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25533436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't find favicon in web page source
提问by HerrimanCoder
Maybe a stupid question, but for the life of me I can't find a reference to the favicon "ico" file on this website:
也许是一个愚蠢的问题,但对于我的生活,我无法在本网站上找到对网站图标“ico”文件的引用:
They obviously have one because it displays in the browser tab/window. I've tried Chrome developer tools, Network tab which shows all images on a page -- but no favicon there either. Where is it hiding?
他们显然有一个,因为它显示在浏览器选项卡/窗口中。我试过 Chrome 开发人员工具,网络选项卡显示页面上的所有图像 - 但那里也没有图标。它藏在哪里?
回答by Ryan
It does seem to be being pulled in differently, but it is typically always in the default location - which this one is as well.
它似乎确实以不同的方式被拉入,但它通常总是在默认位置 - 这也是一个。
回答by Carlos Calla
There are two ways to specify the favicon for a website:
有两种方法可以指定网站的 favicon:
1) Give a link
to the favicon
1) 给link
favicon
<link rel="icon" type="image/png" href="/somepath/favicon.png" />
2) Put it in a prefefined URL, this is relative to the server root. So in this case will be http://www.fitnessutah.com/favicon.ico
2) 把它放在一个预定义的 URL 中,这是相对于服务器根的。所以在这种情况下将是http://www.fitnessutah.com/favicon.ico
This website seems to be using the second method so you will find the favicon in that link.
该网站似乎正在使用第二种方法,因此您可以在该链接中找到图标。
回答by Keir Simmons
You do not need to add a link
element with your favicon image for it to appear on your website.
您无需添加link
带有网站图标图像的元素即可显示在您的网站上。
Quote: A second method for specifying a favicon relies on using a predefined URI to identify the image: "/favicon", which is relative to the server root.
引用: 指定收藏夹图标的第二种方法依赖于使用预定义的 URI 来标识图像:“/收藏夹图标”,它是相对于服务器根目录的。
回答by cssyphus
Further to Keir's and Carlos' answers - to spell it out - most browsers are programmed to also look for a favicon here:
除了 Keir 和 Carlos 的回答 - 详细说明 - 大多数浏览器都被编程为也在此处查找图标:
http://yourwebsitename.com/favicon.ico
If the favicon image is named/stored as above, there is no need to mention it in the HTML code.
如果 favicon 图像如上命名/存储,则无需在 HTML 代码中提及它。
Therefore, if you are looking at a website and you can't find any reference to their favicon in the HTML source, just type the website's base URL in the browser address bar followed by /favicon.ico
:
因此,如果您正在查看一个网站,但在 HTML 源代码中找不到对其网站图标的任何引用,只需在浏览器地址栏中输入网站的基本 URL,然后输入/favicon.ico
:
http://example.com/favicon.ico
Real-life example - try to find the favicon in the source code:
现实生活中的例子 - 尝试在源代码中找到 favicon:
回答by Hopeless
Use Chrome Dev Tools Network tab. Filter by favicon reload the page with Shift+F5 You will get the icon regardless it was loaded with link or from default location
使用 Chrome 开发工具网络选项卡。按 favicon 过滤 使用 Shift+F5 重新加载页面无论它是通过链接加载还是从默认位置加载,您都将获得该图标