【发布时间】:2014-08-25 15:08:23
【问题描述】:
在 Windows 操作系统中,我有一个自定义的 URI 方案,用于
IE、火狐、Opera、Safari、谷歌浏览器
启动瞻博网络路由器 VPN SSH 客户端(如 Cisco)。如果安装了 SSH 客户端,基本上它的工作原理如下,从网页 VPN SSH 客户端可以启动。
<a href="juniper:open"> VPN SSH Client </a>
问题:
有时用户没有从 CD/DVD 盒中安装 Juniper 路由器 SSH 客户端应用程序,因此 juniper:open 什么也不做。
所以在这种情况下,我需要检测天气或 URL 方案是否可用。
因此,我尝试了 Javascript 方法,但它无法正常工作。因为 juniper:open 实际上不是网络链接。
请问我该如何检测呢?
<script>
// Fails
function test1(){
window.location = 'juniper:open';
setTimeout(function(){
if(confirm('Missing. Download it now?')){
document.location = 'https://www.junper-affiliate.com/setup.zip';
}
}, 25);
//document.location = 'juniper:open';
}
// Fails
function test2(h){
document.location=h;
var time = (new Date()).getTime();
setTimeout(function(){
var now = (new Date()).getTime();
if((now-time)<400) {
if(confirm('Missing. Download it now?')){
document.location = 'https://www.junper-affiliate.com/setup.zip';
} else {
document.location=h;
}
}
}, 300);
}
</script>
然后:
<a onclick="test1()">TEST 1</a>
<a href="juniper:open" onclick="test2(this.href);return false;">TEST 2</a>
【问题讨论】:
-
使用 iframe;见this solution。
标签: javascript internet-explorer google-chrome firefox url-scheme