捕获点击超链接的事件? [英] Capture event of clicking on hyperlinks?

查看:88
本文介绍了捕获点击超链接的事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的应用程序中有一个iFrame,它有超链接。当用户单击这些超链接时,将创建该应用程序的新实例。我猜它正在尝试启动超链接的URL。我无法控制超链接。我想在用户点击iFrame中的超链接时捕获
,然后继续停止应用程序打开应用程序的新实例,而是打开设备默认浏览器的实例并打开该超链接在该浏览器中。



有没有办法阻止新的应用程序实例打开,而是打开设备的默认浏览器?

解决方案

Hello AOL,


欢迎来到开发通用Windows应用论坛! 


请阅读棒y帖子,尤其是  引导
发布:主题行标签
 &absp; Windows 10 SDK和工具的已知问题  。 


我们可以停止写
NavigateUri  属性
在我们的控制中并处理 
超链接按钮的点击事件。但是在按钮事件中我们需要做一些特定的事情。打开默认浏览器是一项艰巨的工作,因为在我看来,我们只能使用  LaunchUriAsync
| launchUriAsync方法
以启动特定的URI。由于此限制,我们必须修改我们的URI以使其正常工作。所以请确保默认的Web浏览器有一个协议可以用来导航。例如:


我们可以在按钮点击中使用以下代码来启动应用程序

 private async void HyperlinkBut​​ton_Click(object sender,RoutedEventArgs e)
{
await Launcher.LaunchUriAsync(new Uri(" microsoft-edge:"));
}

但是如果我们想要开始你在这个浏览器中我们还需要这个URI支持我们的超链接站点作为参数。 


顺便说一句,winrt似乎没有办法检测默认的webbrowser。


致以最好的问候,


Barry




I have an iFrame in my app that has hyperlinks. When the user clicks on these hyperlinks, a new instance of the app is created. I am guessing it is attempting to launch the URL of the hyperlink. I have no control over the hyperlink. I would like to capture the event of the user clicking on the hyperlink from within the iFrame and then proceed to stop the app from opening a new instance of the app but instead open an instance of device's default browser and open that hyperlink within that browser.

Is there a way to stop a new app instance from opening and instead open the device's default browser?

解决方案

Hello AOL,

Welcome to the Developing Universal Windows apps forum! 

Please read the sticky posts, especially the Guide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools 

We can stop writing NavigateUri property in our control and handle the click event of hyperlink buttons. But in the button event we need to do some specific thing. To open the default browser is a hard job because in my point of view we can only use LaunchUriAsync | launchUriAsync methods to launch a specific URI. Due to this limit we have to modify our URI to make it works. So please make sure that the default web browser has a protocol which can be used to navigate. For example:

We may be able to use the following code in button click to start an app

 private async void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            await Launcher.LaunchUriAsync(new Uri("microsoft-edge:"));
        }

But if we want to start up this browser we also need this URI support our hyperlink site as the parameter. 

By the way, winrt seems do not have a way to detect default webbrowser.

Best regards,

Barry


这篇关于捕获点击超链接的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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