miguelangelcv miguelangelcv - 1 month ago 5
C# Question

How can I detect when the user clicks on a hyperlink in a WebView control?

I'm trying to detect when the user clicks on a hyperlink in a WebView control from Windows 10. Is there any way to detect this event?

Answer

If you want to catch the click itself you'll need to do that from inside the web page's JavaScript. Depending on where the page comes from you may be able to inject JavaScript code to do so with WebView.InvokeScriptAsync

If you want to detect the navigation triggered by the click then you can handle the WebView.NavigationStarting or NavigationCompleted events.

Comments