积极答复者
vb6 WebBrowser 控件问题

问题
答案
-
直接下载favicon就可以,不需要WebBrowser控件。
参考:
[VB.NET 2008] How to get the favicon.ico of a webpage in a ToolStripComboBox.
- 已标记为答案 sunrui2016 2016年8月26日 1:55
全部回复
-
直接下载favicon就可以,不需要WebBrowser控件。
参考:
[VB.NET 2008] How to get the favicon.ico of a webpage in a ToolStripComboBox.
- 已标记为答案 sunrui2016 2016年8月26日 1:55
-
浏览器tab上的图标,不一定叫做favicon.ico. 它是由Header中的rel="shortcut icon"的link tag指定的,例如微软store网页是这样的
<link rel="shortcut icon" type="image/x-icon" href="//dri1.img.digitalrivercontent.net/Storefront/Site/mscommon/cm/images/common_images/favicon.ico"/>
连接可以通过解析html来取得,例如:
HtmlDocument doc = webBrowser1.Document; HtmlElementCollection collect = doc.GetElementsByTagName("link"); foreach (HtmlElement element in collect) { if (element.GetAttribute("rel").ToUpper() == "SHORTCUT ICON") iconPath = element.GetAttribute("href"); }
string iconPath = "http://" + e.Url.Host + iconPath;
以上代码来自http://www.codeproject.com/Articles/19132/Retrieve-a-Web-Pages-Shortcut-Icon. 做了一些修改,需要放在WebBrowser.DocumentCompleted Event中执行。