HTML
<a class="intent" href="http://mymobilewebsite" data-scheme="myApp://"></a>
的Javascript
(function () {
goToUri($("a.intent").data('scheme'), $("a.intent").attr('href'));
event.preventDefault();
function goToUri(uri, href) {
var start, end, elapsed;
start = new Date().getTime();
document.location = uri;
end = new Date().getTime();
elapsed = (end - start);
if (elapsed < 1) {
document.location = href;
}
}
})();
此代码基于Chase在Here
的回答然而,代码有时候工作有时没有,也无法找出原因?