I want to search b4i webview and highlight the results,I search the forum and find a link:
https://www.b4x.com/android/forum/threads/webview-searching-and-highlight.49348/,I copy the javascript code inside link and make HighLight.js file.Because I don't know much about js, and a newbie to B4i, I use the below code but is not ok.
https://www.b4x.com/android/forum/threads/webview-searching-and-highlight.49348/,I copy the javascript code inside link and make HighLight.js file.Because I don't know much about js, and a newbie to B4i, I use the below code but is not ok.
B4X:
dim JQuery as string
Private Txt_Search as TextField
Private WV_Search as WebView
File.Copy(File.DirAssets,"HighLight.js",File.DirTemp,"HighLight.js")
JQuery= File.Combine(File.DirTemp,"HighLight.js")
WV_Search.LoadHtml($"
<script src="${JQuery}"></script>
"$)
JS($"uiWebview_HighlightAllOccurencesOfString(${Txt_Search.Text}$)"$,WV_Search)
Sub JS (Script As String, WebV As WebView)
Dim NaObj As NativeObject = WebV
NaObj.RunMethod("stringByEvaluatingJavaScriptFromString:", Array(Script))
End Sub
Attachments
Last edited: