Results 1 to 8 of 8

Thread: Getting the title string of the WebBrowser

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Location
    Atlanta
    Posts
    104

    Arrow


    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.

  2. #2
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930

    Smile WebBrowser control

    The title of the page currently loaded into the control can be accessed with the LocationName property: WebBrowser.LocationName
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Location
    Atlanta
    Posts
    104
    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.

  4. #4
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930

    WebBrowser oddities

    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.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Location
    Atlanta
    Posts
    104
    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. =).

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Location
    Atlanta
    Posts
    104
    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.

  7. #7
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    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:
    Code:
    Text1.Text = WebBrowser1.Document.DocumentElement.InnerHTML
    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".

    I'll mess around with a searcher for the heck of it. I'm bored.
    I'm baaaack...
    VB5 Professional Edition, VC++ 6
    Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se

    I feel special because I finally figured out how to loop midis: Post link
    I'm a fanatic too

  8. #8
    Member
    Join Date
    Aug 2000
    Location
    Chennai , India
    Posts
    44

    Cool

    Try this:
    Code:
    Private Sub WebBrowser1_TitleChange(ByVal Text As String)
    Me.Caption = Text
    End Sub
    Rabin
    Windows : Visual Basic 6 Enterprise / 3.0 (16-bit)
    DOS : QBasic 4.5 , Visual Basic For DOS
    Web : HTML , VBScript , PHP (Learning)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width