I need to be pointed in the direction of a good article or tutorial for the WebBrowser component.
I would like to be able to retrieve the title from a WebBrowser. I can use LocationUrl to get the url, but what way is there to get the title?
Thanks.
Printable View
I need to be pointed in the direction of a good article or tutorial for the WebBrowser component.
I would like to be able to retrieve the title from a WebBrowser. I can use LocationUrl to get the url, but what way is there to get the title?
Thanks.
The title of the page currently loaded into the control can be accessed with the LocationName property: WebBrowser.LocationName
That is helpful, but I have already tried that. =).
That returns the exact name of the file currently in the WebBrowser (ie. index.html or whatever, minus the path / url).. LocationName works the same as the commondialog.filetitle, and LocationUrl works like the commondialog.filename.
You know the title that appears in the title bar of an explorer or netscape window?.. That's the string I'm looking to grab. I'm hoping that there is an easy way to do it, but either way, I'm looking for the answer.
I'll keep you posted if I find it.
Thanks.
Yeah, I did some testing just before I posted, and when I looked at a local file, LocationName returned the exact filename. If I got something from the net though, LocationName returned the HTML title. Why? (maybe someone else can answer). I don't think I was seeing some weird glitch, but on a 5 year old comp, seeing a glitch isn't rare :). And about the other things, I asked that same question a few days earlier, and Matthew Gates passed me some links (I apologize if I goof the vB code thingy).
http://visualbasic.about.com/library...?terms=Browser - How to make a browser from About.com
http://msdn.microsoft.com/workshop/b...webbrowser.asp - WebBrowser Tutorial from Microsoft
Look in the Object Browser too (press F2 in VB). It will list all the properties/events/etc of eveything that exists in the current project. It is bare, but does help some.
Thanks a bunch!
I looked around a bit before I posted and I've looked around more after. I've found a little, but any useful tutorials or information is great.
Thanks for the links.
If anyone else can suggest anything I think it could be useful to the both of us. =).
I'm still looking for a decent answer to this question.. if it is possible, or other wise.
The only other way I can think to do this is by reading the content of the html as it loads looking for the <title> </title> string. Neither one of these should be that complicated, (reading the content of the html loading, or getting the title string) and I'm sure they're built in to some lib somewhere or another. I just don't know where or how to call it.
Any information would be useful.
Thanks.
I don't know if any kinds of things exist out there that will do that already, but if you want to make up your own, you can get the HTML source using this:
This doesn't appear in the object browser, and if Matthew Gates hadn't told me about when I asked about viewing a page's source, I would have never found it. It would be fairly easy to make up a search thing using this. I think I'm going to myself. I'm getting tired of this little "undocumented feature".Code:Text1.Text = WebBrowser1.Document.DocumentElement.InnerHTML
I'll mess around with a searcher for the heck of it. I'm bored. :)
Try this:
Code:Private Sub WebBrowser1_TitleChange(ByVal Text As String)
Me.Caption = Text
End Sub