我创建了一个自定义URL协议处理程序.
http://
mailto://
custom://
我已经注册了一个WinForms应用程序来做出相应的响应.一切都很好.
但我希望能够优雅地处理用户尚未安装自定义URL协议处理程序的情况.
为了能够做到这一点,我需要能够检测浏览器的注册协议处理程序,我想从JavaScript.但我一直无法找到一种方法来查询信息.我希望找到解决这个问题的方法.
感谢您提供的任何想法.
在我的网站上,我有几个这样的链接:
<a href="tel://+12181112222" class="call">218.111.2222</a>
我想使用jQuery(或其他方法)来确定设备是否支持使用tel://协议进行调用.这种方法在世界上存在吗?
我想使用一些方法来启用或禁用链接,因为当点击桌面时,我们来到一个页面,如"Firefox不知道如何打开这个地址,因为协议(tel)与任何程序都没有关联. "
目前,我正在嗅探用户代理并检测它是否是移动设备.但是,有更好/准确的方法吗?像jQuery的东西$.support.xx?
if ( (/iPhone|iPod|iPad|Android|BlackBerry/).test(navigator.userAgent) != true ){
$(".call").attr("href", "#");
}
Run Code Online (Sandbox Code Playgroud) 因此,如果您想要链接到电话号码,您可以执行类似的操作
<a href="tel:18005555555">Click to Call</a>
Run Code Online (Sandbox Code Playgroud)
这在移动网站上常用,并且在桌面网站上也越来越受欢迎(主要得益于我认为的Skype).但是有些计算机/设备无法支持它.有没有办法告诉用户是否能够处理tel:links?
解决方案可以是服务器端或客户端,但我认为它需要是客户端.
有两种方法可以在HTML中使用点击呼叫链接
<a href="wtai://wp/mc;+1800229933</a> WTAI风格(诺基亚,其他)
<a href="tel:+1-800-275-2273">Call Apple Customer Support at 1-800-275-2273</a>. TEL风格(Apple)
怎么可以
检测Javascript中当前用户代理支持的格式?
是否可以在不依赖用户代理字符串的情况下进行检测
更多信息
在Windows操作系统中,我有一个自定义URI方案,使用它
IE,Firefox,Opera,Safari,Google Chrome
推出Juniper路由器VPN SSH客户端(如思科).基本上,如果安装了SSH客户端,它的工作原理如下,从网页上可以启动VPN SSH Client.
<a href="juniper:open"> VPN SSH Client </a>
Run Code Online (Sandbox Code Playgroud)
问题:
有时用户没有从CD/DVD盒安装Juniper路由器SSH客户端应用程序,因此juniper:open什么都不做.
所以在这种情况下,我需要检测天气是否可用URL方案.
因此,我尝试了Javascript方法,但它没有完全正常工作.因为juniper:open实际上不是web链接.
我如何检测它呢?
<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>
Run Code Online (Sandbox Code Playgroud)
然后:
<a onclick="test1()">TEST 1</a> …Run Code Online (Sandbox Code Playgroud) javascript firefox internet-explorer google-chrome url-scheme
$(function () {
$("div[href]").click(function (event) {
debugger;
//for validation purpose.
window.location = "abcd:";
//if it is validated then
window.location ="xyz:";
});
});Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Custom Protocol Detection</title>
</head>
<body id="abcd">
<h1>Click one of these labels:</h1>
<a href="#" id="atemp"></a>
<div href="blahblah:randomstuff" style="background-color:aquamarine">
Non-exist protocol
</div>
<div href="mailto:johndoe@somewhere.com" style="background-color:aqua">
Send email
</div>
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="example.js"></script>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
我已经根据https://gist.github.com/aaronk6/d801d750f14ac31845e8实施了一个解决方案 ,它一直工作到 chrome 85 。使用最新的 chrome Update Onblur 没有检测到开放协议处理程序弹出窗口。有没有办法使用 Chrome 86 新版本识别在 windows 中注册的自定义协议。下面提到的我实现的代码,它适用于 Firefox
function LinkClicked() {
launchUri($(this).attr("href"), function () {
// SUCCESS APPLICATION INSTALLED
}, function () {
// PROTOCOL NOT REGISTERD IN REGISTRY
setTimeout(showAppInstallWarningMessage, 4000);
}, function () {
// STATUS CANNOT IDENTIFY
setTimeout(showAppInstallWarningMessage, 4000);
});
}
function launchUri(uri, successCallback, noHandlerCallback, unknownCallback) {
var res, parent, popup, iframe, timer, timeout, blurHandler, timeoutHandler, browser;
function callback(cb) {
if (typeof cb === 'function') cb();
}
function createHiddenIframe(parent) …Run Code Online (Sandbox Code Playgroud) javascript google-chrome custom-protocol chromium google-chrome-app