[UWP] [HTML] iFrame中的链接无法在默认浏览器中打开 [英] [UWP][HTML]Link in iFrame not opening in default browser

查看:129
本文介绍了[UWP] [HTML] iFrame中的链接无法在默认浏览器中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iFrame。因为iFrame有一个按钮,它应该在系统的默认浏览器中打开一个网页。当在浏览器窗口中访问网页时,就会发生这种情况 - 新的浏览器窗口会打开相关链接。



但是,当在Windows 10商店应用程序中的iFrame中单击相同的按钮时,它不会在默认浏览器中打开网页,而是尝试在Windows 10商店应用程序的新实例中打开应用程序。



  1. 我可以在应用程序中更改哪些内容,以便在系统的默认浏览器中打开?或者......
  2. 我可以在iFrame指向的网页中更改哪些内容,以便应用在系统的默认浏览器中打开链接?



ps Windows应用商店应用是使用JavaScript创建的。


 

解决方案

您好Jaxim,



您可以使用< x-ms-webview>而不是< iframe>使用JavaScript时。它的默认行为是打开系统的默认浏览器。 (当MSWebViewNewWindowRequested事件引发时,您也可以取消它。)

https://msdn.microsoft.com/en-us/library/windows/apps/dn301831.aspx  

有关详细信息,请参阅官方WebView示例。

https://github.com/Microsoft/Windows- universal-samples / tree / master / Samples / WebView &bbsp


最好的问候,

David

I have an iFrame. In that iFrame has a button which is supposed to open a webpage within the system's default browser. When the webpage is accessed within a browser window, then this is exactly what happens - a new browser window opens to the link in question.

However, when the same button is clicked within an iFrame within a windows 10 Store app, then instead of opening the webpage in the default browser, it instead attempts to open the app within a new instance of the windows 10 Store app.

  1. What can I change within the app so it instead opens in the system's default browser? or...
  2. What can I change within the webpage that the iFrame is pointing to so the app opens the link in the system's default browser?

p.s. The Windows Store app was created using JavaScript.

 

解决方案

Hi Jaxim,

You could use <x-ms-webview> instead of <iframe> while using JavaScript. Its default behavior is to open system’s default browser. (You could also cancel it when the MSWebViewNewWindowRequested event raised.)
https://msdn.microsoft.com/en-us/library/windows/apps/dn301831.aspx 
For more information, please refer to the official WebView sample.
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/WebView 

Best Regards,
David


这篇关于[UWP] [HTML] iFrame中的链接无法在默认浏览器中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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