如何检测用户何时单击 WebView 控件中的超链接? [英] How can I detect when the user clicks on a hyperlink in a WebView control?

查看:25
本文介绍了如何检测用户何时单击 WebView 控件中的超链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检测用户何时单击 Windows 10 中 WebView 控件中的超链接.有什么方法可以检测到此事件?

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?

推荐答案

如果您想捕捉点击本身,您需要在网页的 JavaScript 中执行此操作.根据页面的来源,您可以使用 WebView.InvokeScriptAsync

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

如果您想检测由点击触发的导航,那么您可以处理 WebView.NavigationStartingNavigationCompleted 事件.

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

这篇关于如何检测用户何时单击 WebView 控件中的超链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆