如何检查是否支持自定义协议

我们正在使用注册自己的协议的软件。我们可以从浏览器运行应用程序,然后通过以下链接:


customprotocol://do_this.

但是有没有办法检查用户系统是否支持这种自定义协议?如果不是,我们想请用户先安装软件。


例如:


if (canHandle ('customprotocol')) {

     // run software

}

else {

    // ask to install

}

编辑 我知道关于protocolLong属性,但是它仅在IE中有效。


叮当猫咪
浏览 679回答 3
3回答

拉风的咖菲猫

Windows 8上的Internet Explorer 10引入了非常有用的navigator.msLaunchUri方法,用于启动自定义协议URL并检测成功或失败。例如:        if (typeof (navigator.msLaunchUri) == typeof (Function)) {            navigator.msLaunchUri(witchUrl,                function () { /* Success */ },                function () { /* Failure */ showError(); });            return;        }Windows 7 / IE 9及以下版本支持@ mark-kahn建议的条件注释。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript