Wisej.Web.WebBrowser.eavl(JS) do not works

0
0

Wisej.Web.WebBrowser.eavl(JS) do not works

In this code, please advise:

Public Class CTreeView_basic_01_ForBooks
Inherits TreeView

Dim OWebBrowser As Wisej.Web.WebBrowser

Public Sub New(INOGuid As Guid, ByRef INoWebBrowser As Wisej.Web.WebBrowser)
OWebBrowser = INoWebBrowser

With Me
.Dock = DockStyle.Fill
.ShowPlusMinus = True
.ShowRootLines = True
.ShowNodeToolTips = True
End With

End Sub

Private Sub CTreeView_basic_01_NodeMouseClick(sender As Object, e As TreeNodeMouseClickEventArgs) Handles Me.NodeMouseClick
Dim OTreeNode As TreeNode = e.Node

Dim searchText As String = OTreeNode.Text

Dim js As String =
“var found = false;
var el = document.body;
if (el.innerText.includes(‘” & searchText.Replace(“”””, “\”””) & “‘)) {
el.style.backgroundColor = ‘yellow’;
found = true;
}
if (!found) alert(‘Nothing Found’);”

OWebBrowser.Eval(js)

End Sub

End Class

 

 

 

 

  • You must to post comments
0
0

When it is in tje test application (pllease find attached) I at least receive “Nothing found” message.

When iti si in a contro – there is nothing! Why so?

 


Public Class C_Books_Container
Inherits Panel
Private ОWebBrowser As New CUtils.CInterfaceIni.CInterface.C_Wisej_Web_WebBrowser
Public WithEvents OTV As New CUtils.CInterfaceIni.CInterface.CTreeViewS.CTreeView.CTreeView_basic_01(Guid.NewGuid)
Private OSplitContainer As New SplitContainer

Public Sub New(INOStrURLText As String, INOSTRDelimiter As String, INOSTRDelimiter_Internal As String)
ОWebBrowser.Dock = DockStyle.Fill
OTV.Dock = DockStyle.Fill

With OSplitContainer
.Dock = DockStyle.Fill
.Panel1.Controls.Add(OTV)
.Panel2.Controls.Add(ОWebBrowser)
End With
ОWebBrowser.Url = New Uri(INOStrURLText)
Dim OStringPageContent As String = GetTextFromUrl(INOStrURLText)
F_TableОfContents_Get(OTV, OStringPageContent, INOSTRDelimiter, INOSTRDelimiter_Internal)

Me.Dock = DockStyle.Fill
Me.Controls.Add(OSplitContainer)

End Sub

Private Sub OTV_NodeMouseClick(sender As Object, e As TreeNodeMouseClickEventArgs) Handles OTV.NodeMouseClick

Dim searchText = “5”

Dim js As String =

var found = false;
var elements = document.getElementsByTagName(‘*’);
for (var i = 0; i < elements.length; i++) {
if (elements[i].innerText && elements[i].innerText.includes(‘” & searchText.Replace(“”””, “\”””) & “‘)) {
elements[i].scrollIntoView({behavior: ‘smooth’, block: ‘center’});
elements[i].style.backgroundColor = ‘yellow’;
found = true;
break;
}
}
if (!found) {
alert(‘Nothing found.’);
}

ОWebBrowser.Eval(js)

End Sub

End Class

 

 

 

  • You must to post comments
0
0

Javascript is executed by the browser. So I used google and found why your “code” doesn’t work.

https://stackoverflow.com/ questions/3999101 /get-iframes-document-from-javascript-in- main- document

  • You must to post comments
0
0

Nothing at all, complete silence and darkness.

  • JD
    • JD
    • Jul 27, 2025 - 12:21 pm
    Turn the light on?
  • You must to post comments
0
0

Hi,

“does not work” means what? Do you get an error in the console?
We need a test case with a clear indication of expected result to check this.

Best regards
Frank

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.