简体   繁体   English

在浏览器中检查自定义URL方案

[英]Check for custom URL scheme in browser

I have an application that registers a new URL scheme when it's installed and I'm looking for a reliable way to launch this application from our web interface. 我有一个应用程序,该应用程序在安装时会注册一个新的URL方案,并且正在寻找一种可靠的方法来从我们的Web界面启动该应用程序。

Right now I have an IFrame hidden away which I will update it's source after a button is clicked to launch the application, but it seems that in Internet Explorer the parent window always captures the URL scheme not recognized error and navigates to the location it can't understand anyway. 现在,我隐藏了一个IFrame,单击该按钮以启动该应用程序后,我将更新它的源代码,但是似乎在Internet Explorer中,父窗口始终会捕获URL方案未识别的错误,并导航至可以定位的位置。反正还是不明白。

So my question: Is there a way for a programmer to check to see if a scheme is supported by a browser before attempting to navigate to the new URI to direct a user to download the application first? 所以我的问题是:在尝试导航到新的URI以指导用户首先下载应用程序之前,程序员是否有办法检查浏览器是否支持该方案?

You cannot check for URL schemes installed on the device. 您无法检查设备上安装的URL方案。

What you can do is this: 您可以执行以下操作:

setTimeout(function () { window.location = "appCustomUrlSchemeHere"; }, 25);

window.location = "fallbackUrlHere"; window.location =“ fallbackUrlHere”;

But I imagine that will still cause issues in IE as it will attempt to open the URL scheme. 但是我想这仍然会在IE中引起问题,因为它将尝试打开URL方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM