I have a Windows Forms WebBrowser control embedded in my application. Is there any way to get a web pages favicon using either the WebBrowser or HtmlDocument API? Even obtaining it from the local file system would suffice. Downloading the icon as a separate operation would be a last resort...
Thanks.
Just download the /favicon.ico file using a GET or something similar (like you would for any other file).
You can also parse the page to find the favicon that might be also a png. By default it's an ICO file.
The location of favicon file is usually in <link rel="shortcut icon" href="/favicon.ico" />
in the <head>
node of the page.
Also, some browsers by default try to download /favicon.ico (that is, the favicon.ico file in the root folder of the website) without checking the page for that element.
Other idea would be using Google's S2:
http://www.google.com/s2/favicons?domain=youtube.com
(Try it)
This will get you a 16x16 PNG image of youtube's ICO favicon.
http://www.google.com/s2/favicons?domain=stackoverflow.com
(Try it)
This will get you the stackoverflow favicon in the same format.
It might seem awesome but don't forget, this Google service is not officially supported and they might remove it at anytime.
And the webbrowser control doesn't have an address bar, so it does not have application programming interface for address bar features like favicon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With