它的行为与浏览器不一致。
Google Chrome:可以调用第一个,但不能调用另一个。
$(function () {
$("div[href]").click(function (event) {
debugger;
window.protocolCheck("abcd:",
function () {
console.log('err1')
}, function () {
console.log('succ1');
window.protocolCheck("xyz:",
function () {
console.log('err2');
}, function () {
console.log('succ2');
});
});
});
});
<!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="https://github.com/ismailhabib/custom-protocol-detection/blob/master/protocolcheck.js"></script>
<script src="example.js"></script>
</body>
</html>
我想在用户注册表中验证是否存在某些协议。
如果没有找到注册表,我们下载它,如果找到我们调用下一个协议。
库 https://github.com/ismailhabib/custom-protocol-detection/blob/master/protocolcheck.js
对于调用,我们可以使用协议检查 库。