Created
December 23, 2014 09:13
-
-
Save foru17/516f9f6bbc55d8265831 to your computer and use it in GitHub Desktop.
通过js调用Android APP的方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tryOpenQV: function(url) { | |
var targetOpenUrl = 'tenvideo2://?action=4'; | |
var targetDownloadUrl = 'http://mcgi.v.qq.com/commdatav2?cmd=4&confid=107&platform=aphone'; | |
if (!IsAndroid) { | |
targetDownloadUrl = 'https://itunes.apple.com/cn/app/id458318329?mt=8'; | |
} | |
setTimeout(function() { | |
var startTime = (new Date).valueOf(); | |
if (IsAndroid) { | |
var e = document.createElement("iframe"); | |
e.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;"; | |
e.src = targetOpenUrl; | |
document.body.appendChild(e); | |
startTime = (new Date).valueOf(); | |
setTimeout(function() { | |
var endTime = (new Date).valueOf(); | |
if (1550 > endTime - startTime) { | |
location.href = targetDownloadUrl; | |
} | |
}, 1500); | |
} else { | |
// location.href = targetOpenUrl; | |
location.href = targetDownloadUrl; | |
} | |
}, 100); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment