### Get History as List

To get the history entries in a list, use JavaObjects to access.
More information: http://docs.oracle.com/javafx/2/api/javafx/scene/web/WebHistory.html
Define the WebView
`Sub Process_Globals
Private wvwMain As WebView
...
End Sub`
Get the History Entries
' Assign the webview to a JavaObject
Dim joWV As JavaObject = wvwMain
' Get the history and assign to a JavaObject
Dim joHL As JavaObject = joWV.RunMethodJO("getEngine", Null).RunMethod("getHistory", Null)
Dim l As List
l.Initialize
' Get all entries and put on a list
l.AddAll(joHL.RunMethod("getEntries", Null))
' Show the list
Log(l.Size)
'[url: http://www.google.de/?gfe_rd=cr&ei=nNK6U7CDFIym8weeiIG4BQ, title: Google, date: Mon Jul 07 19:02:24 CEST 2014]
For i = 0 To l.Size - 1
Log(l.Get(i))
Next
Hint:
If an entry needs to be split in url, title, date make use RegEx.split.
Dim s() As String = Regex.Split(",", l.Get(i))
Log(s(0))
OR removing the url tag:
Log(s(0).Replace("[url: ", ""))
Example getting history list with unique entries
Private wvwMain As WebView
`Sub getHistory As List
' Assign the webview to a JavaObject
Dim joWV As JavaObject = wvwMain
' Get the history and assign to a JavaObject
Dim joHL As JavaObject = joWV.RunMethodJO("getEngine", Null).RunMethod("getHistory", Null)
Dim l As List
l.Initialize
' Get all entries and put on a list
l.AddAll(joHL.RunMethod("getEntries", Null))
' Build the unique list
Dim nl As List
nl.Initialize
'Example entry to extract url from
'[url: http://www.google.de/?gfe_rd=cr&ei=nNK6U7CDFIym8weeiIG4BQ, title: Google, date: Mon Jul 07 19:02:24 CEST 2014]
For i = 0 To l.Size - 1
Dim s() As String = Regex.Split(",", l.get(i))
Dim url As String = s(0).Replace("[url: ", "")
If nl.IndexOf(url) = -1 Then nl.Add(url)
Next
Return nl
End Sub`
This can be used for example to assign to a combobox listing the history:
Private cbURLHistory As ComboBox
Private wvwMain As WebView
`Sub wvwMain_PageFinished (Url As String)
...
cbURLHistory.Items.Clear
cbURLHistory.Items.AddAll(getHistory)
...
End Sub`

Changed: 2018-05-03 08:50, Category: WebView, File: T6C284M2131.htm, ID: 2131