### Get WebPage Title

To get the title of the current page loaded in a webview, use JavaObject Methods.
Get the current web page title loaded in a webview
' Parameter: WebView
' Returns WebPage Title
`Sub getWebPageTitle(wv As WebView) As String
Dim result As String = ""
Try
' Get the webview
Dim joWV As JavaObject = wv
' See here for the JavaFX webview class (javafx.scene.web.WebView):
' http://docs.oracle.com/javafx/2/api/javafx/scene/web/WebView.html
' Get the webengine from the webview using method getEngine
Dim joWE As JavaObject = joWV.RunMethod("getEngine", Null)
' See here for the JavaFX webengine class (javafx.scene.web.WebEngine):
' http://docs.oracle.com/javafx/2/api/javafx/scene/web/WebEngine.html
' Obtain the page title from the webengine JavaObject using method getTitle
result = joWE.RunMethod("getTitle", Null)
Catch
result = LastException.Message
End Try
Return result
End Sub`
Usage:
Private wvwMain As WebView
MainForm.Title = getWebPageTitle(wvwMain)
Get the current Location for the WebPage loaded
Same principle as above but using WebEngine Method getLocation.
This is a shorter version of the previous Sub:
`Sub getWebPageLocation(wv As WebView) As String
Dim result As String = ""
Try
Dim joWV As JavaObject = wv
Return joWV.RunMethodJO("getEngine", Null).RunMethod("getLocation", Null)
Catch
result = LastException.Message
End Try
Return result
End Sub`

Changed: 2018-05-03 08:50, Category: WebView, File: T6C284M2132.htm, ID: 2132