Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
VB.NET
VB.NET General Discussion
How to get favicon in tabbed webbrowser. Tutorial
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="stianxxs, post: 121485, member: 29339"] Hi, many of you are may working on some sort of project with web browser related settings or information, so to day I'm gonna demonstrate how to get favicon in a tabbed web browser! It's is actually quite simple. But I've been searching for this "How to get favicon in web browser" and i found many answers, but not the right one. because in all the samples I've been seeing you can't type i.e "http://www.google.com" you need to type "www.google.com" because you need to add "http://" in the source of the request! But I'm gonna show you how to get your user to type "http://www.google.com" or "www.google.com" because the web browser need "http://" to get response from the server! So first we need to declare our settings [CODE]CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(txtAdress.Text)[/CODE] We get our web browser to go to the url from txtAdress [CODE]Dim stringadress As String = txtAdress.Text Dim outstring() As String Dim Seps() As Char = {"h", "t", "t", "p", ":", "/", "/"}[/CODE] We declare where we want to split the URL, and this is how we don't get stuck by typing "http://" in every URL! [CODE]Try outstring = stringadress.Split("h", "t", "t", "p", ":", "/", "/") For i = 0 To outstring.Length - 1 outstring = stringadress.Split(Seps, StringSplitOptions.RemoveEmptyEntries) MsgBox(outstring(i)) 'We send the splitted string to a label that corrects it txtAdressCheck.Text = outstring(i) txtAdress.Text = "http://" & txtAdressCheck.Text 'We have removed the "http://" earlier and can now safe add "http://" to every splitted URL[/CODE] "txtAdre We get our web browser to TRY to split the string txtAdress.text that we declared earlier. [CODE]Dim url As Uri = New Uri(txtAdress.Text) If url.HostNameType = UriHostNameType.Dns Then[/CODE] Checks the string if it have the "http://" in front of the URL [CODE]Dim browser As New WebBrowser Dim iconURL = "http://" & txtAdressCheck.Text & "/favicon.ico" Dim request As System.Net.WebRequest = System.Net.HttpWebRequest.Create(iconURL) Dim response As System.Net.HttpWebResponse = request.GetResponse() Dim stream As System.IO.Stream = response.GetResponseStream() Dim favicon = Image.FromStream(stream) 'Fav Icon ImgFavIco.Image = favicon[/CODE] And finally gets the requested favicon in our imagebox! Did this help? or not? Leave a comment! :) Sorry for my bad English! I'm from Norway [/QUOTE]
Insert quotes…
Verification
Post reply
VB.NET
VB.NET General Discussion
How to get favicon in tabbed webbrowser. Tutorial
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom