Created
May 7, 2014 12:28
-
-
Save sandywu/3b36b437312a62938ca7 to your computer and use it in GitHub Desktop.
客户端唤起
This file contains hidden or 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
var browser = { | |
versions: function () { | |
var u = navigator.userAgent, app = navigator.appVersion; | |
return {//移动终端浏览器版本信息 | |
trident: u.indexOf('Trident') > -1, //IE内核 | |
presto: u.indexOf('Presto') > -1, //opera内核 | |
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 | |
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核 | |
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端 | |
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 | |
android: u.indexOf('Android') > -1, //android终端 | |
iPhone: u.indexOf('iPhone') > -1, //是否为iPhone | |
iPad: u.indexOf('iPad') > -1, //是否iPad | |
webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部 | |
}; | |
} (), | |
language: (navigator.browserLanguage || navigator.language).toLowerCase() | |
} | |
if(browser.versions.iPhone || browser.versions.iPad) { | |
} else { | |
} | |
var autoDetector = true ,timer = null; | |
function autoHandler(){ | |
if(timer !== null){return} | |
if(browser.versions.iPhone || browser.versions.iPad) { | |
var appstore = 'http://itunes.apple.com/cn/app/ju-hua-suan-pin-zhi-tuan-gou/id534159732?spm=608.1000926.0.53.45da11&ls=1&mt=8'; | |
location.href="jhsExSupport://url/?%7B%22type%22%3A2%2C%22title%22%3A%22%22%2C%22url%22%3A%22http%3A%2F%2Fju.taobao.com%2Fm%2Fjusp%2Fwlh%2Fmtp.htm%22%7D"; | |
//setTimeout(function(){ | |
var clickedAt = +new Date; | |
timer = setTimeout(function(){ | |
// To avoid failing on return to MobileSafari, ensure freshness! | |
if (+new Date - clickedAt < 2000){ | |
window.location = appstore ; | |
} | |
}, 500); | |
// },500); | |
} else if (browser.versions.android) { | |
//Android目前无法处理 | |
window.location = 'http://www.taobao.com/go/act/juhuasuan/android-latest-download.php' ; | |
} | |
} | |
function handler(){ | |
if(browser.versions.iPhone || browser.versions.iPad) { | |
var appstore = 'http://itunes.apple.com/cn/app/ju-hua-suan-pin-zhi-tuan-gou/id534159732?spm=608.1000926.0.53.45da11&ls=1&mt=8'; | |
location.href="jhs://nowhere"; | |
//setTimeout(function(){ | |
var clickedAt = +new Date; | |
timer = setTimeout(function(){ | |
// To avoid failing on return to MobileSafari, ensure freshness! | |
if (+new Date - clickedAt < 2000){ | |
window.location = "jhsExSupport://url/?%7B%22type%22%3A2%2C%22title%22%3A%22%22%2C%22url%22%3A%22http%3A%2F%2Fact.ju.taobao.com%2Fmarket%2Fju%2Fleehom.php%22%7D" ; | |
} | |
}, 500); | |
// },500); | |
} else if (browser.versions.android) { | |
//Android目前无法处理 | |
window.location = 'http://www.taobao.com/go/act/juhuasuan/android-latest-download.php' ; | |
} else { | |
//没有Store,去高端版 | |
window.location = 'http://ju.taobao.com' ; | |
} | |
} | |
if(autoDetector){ | |
setTimeout(function(){ | |
autoHandler() | |
},2000); | |
} | |
var androidlink = document.getElementById('android-download'); | |
androidlink.setAttribute("href","http://www.taobao.com/go/act/juhuasuan/android-latest-download.php"+location.search); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment