This works well: Found at: Mouse Event for detecting if mouse is hovering over URL
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
AddHandler WebBrowser1.Document.MouseOver, AddressOf Me.DisplayHyperlinks
End Sub
Public Sub DisplayHyperlinks(ByVal sender As Object, ByVal e As System.Windows.Forms.HtmlElementEventArgs)
TextBox4.Text = e.ToElement.GetAttribute("href")
End Sub
Or:
Getting the URL that the mouse is over in a web browser. [Tutorial] (Awesomium)-VBForums
I searched all over the place to find a way to show the URL that the mouse was hovering over in the Awesomium web control, but I finally found it and I figured I would share it for anybody that was having the same issue I was. Although it is a VERY easy thing to do. Step 1: Add a label to the...www.vbforums.com
WebBrowser
control. That is not the same as the WebView2
control, but I'm not aware of what similarities and differences there are. Did you test that solution with a WebView2
control to see whether it actually addresses the OP's question?That appears to be for an AwesomiumWebBrowser
control. That is not the same as theWebView2
control, but I'm not aware of what similarities and differences there are. Did you test that solution with aWebView2
control to see whether it actually address the OP's question?
That appears to be for an AwesomiumWebBrowser
control. That is not the same as theWebView2
control, but I'm not aware of what similarities and differences there are. Did you test that solution with aWebView2
control to see whether it actually address the OP's question?
Rythorian77 , I write the program in VisualBasic not in Visual C
Rythorian77 , I write the program in VisualBasic not in Visual C
how to read the URL under the mouse with a web browser using webview2
ExecuteScriptAsync
method, and to get the event back to VB app you can send messages from script with window.chrome.webview.postMessage
and handle the WebMessageReceived
event.document.querySelectorAll("a").forEach(element => {
element.addEventListener("mouseover", e => {
window.chrome.webview.postMessage(e.target.href);
});
});
Private Sub WebViewExample_NavigationCompleted(sender As Object, e As CoreWebView2NavigationCompletedEventArgs) Handles WebViewExample.NavigationCompleted
Dim scriptPath = Path.Combine(Application.StartupPath, "script.js")
Dim script = File.ReadAllText(scriptPath)
WebViewExample.ExecuteScriptAsync(script)
End Sub
Private Sub WebViewExample_WebMessageReceived(sender As Object, e As CoreWebView2WebMessageReceivedEventArgs) Handles WebViewExample.WebMessageReceived
Debug.WriteLine(e.TryGetWebMessageAsString)
End Sub