Post by FreeApp Software on Jan 7, 2017 8:32:23 GMT 10
Hey there. I am trying to make the WebBrowser using CEFSharp (Chromium Web Engine) So I would like to know how to know the current webpage title. I was able to get the webpage URL, not title. This code makes the thing hang: Dim A As Task = wb.EvaluateScriptAsync("document.title") Dim B As JavascriptResponse = wb.EvaluateScriptAsync("document.title").Result WithEvents TW As New Timer
Private Sub wb_TitleChanged(sender As Object, e As TitleChangedEventArgs) Handles wb.TitleChanged
A.Start() With TW .Interval = 10 End With TW.Start()
End Sub Private Sub TWEnd() Handles TW.Tick If A.IsCompleted = True Then MsgBox(B.ToString) End If End Sub
Hope to get help
|
|
Post by bobowk on Jan 7, 2017 10:23:09 GMT 10
|
|
Post by FreeApp Software on Jan 7, 2017 23:51:20 GMT 10
Well I read this documentation 999+ times and gotta say it is useless
|
|
Post by knowledge on Jan 8, 2017 6:53:57 GMT 10
Hey. Can you gimmie the link of the library since i cannot find it?
|
|
Post by FreeApp Software on Jan 8, 2017 7:05:17 GMT 10
Hey. Can you gimmie the link of the library since i cannot find it? Get it from NuGet. Go to the menu bar, Project, Manage NuGet packages, go to the first tab, type in search "cef" and install "CefSharp.WinForms" or "CefSharp.Wpf" (if you are using WPF)
|
|
Post by bobowk on Jan 8, 2017 19:27:53 GMT 10
Try making it search through the source and find <title>. Get the text after <title> but before </title>. That'll be where you can get it.
|
|
Post by FreeApp Software on Jan 8, 2017 19:39:22 GMT 10
Try making it search through the source and find <title>. Get the text after <title> but before </title>. That'll be where you can get it. Will the <title> change if the title was changed by JavaScript?
|
|
Post by Nathan Lecompte on Jan 10, 2017 6:09:21 GMT 10
There's an event for that; the "OnTitleChanged" event, it'll allow you to get the title fairly easily, you can retrieve the title within the event with this: e.Title So, for example: If you have a label control called "Label1", and you want its' value to equal to that of the title of the currently loaded website in the CEF browser control, "Browser", you'd have something like this: Private Sub Browser_TitleChanged(sender As Object, a As CefSharp.TitleChangedEventArgs) Handles Browser.TitleChanged Label1.Text = e.Title End Sub
The event will be triggered every time the title changes, and the accompanying values ("e.Title") should update accordingly.
|
|
Post by FreeApp Software on Jan 10, 2017 20:22:12 GMT 10
|
|
Post by FreeApp Software on Jan 10, 2017 20:22:45 GMT 10
Thank you a lot. I was trying to do it using Javascript. ..
|
|