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?
Asked
Active
Viewed 2,187 times
2 Answers
3
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.

Rob Caplan - MSFT
- 21,714
- 3
- 32
- 54
1
On Windows 10 I would use the WebView.NewWindowRequested
event:
private void WebView1_NewWindowRequested(WebView sender, WebViewNewWindowRequestedEventArgs args)
{
Debug.WriteLine(args.Uri);
args.Handled = true; // Prevent the browser from being launched.
}

JKennedy
- 18,150
- 17
- 114
- 198