js 调起APP(安卓和IOS)

 
分享一段 js 调起APP(android和IOS)的代码:
 
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JS调起APP</title>
<meta name='apple-itunes-app' content='app-id=1309411684'><!--作用:苹果safari头部,如果已安装显示打开,没安装显示去下载-->
</head>
<body>
<a href="javascript:;" id="openApp">调起APP</a>
</body>
</html>
<script type="text/javascript">
document.getElementById('openApp').onclick = function(e){

if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i))
{
window.location.href = "cnchat://";//ios app协议(ios开发人员提供)
window.setTimeout(function() {
window.location.href = "https://itunes.apple.com/cn/app/%E5%90%B9%E7%89%9B-%E6%A3%8B%E7%89%8C%E4%BA%A4%E5%8F%8B%E8%81%8A%E5%A4%A9%E5%B9%B3%E5%8F%B0/id1309411684?mt=8";
//app store 下载地址
}, 2000)
}
if(navigator.userAgent.match(/android/i))
{
window.location.href = "cn://brotheraides";//android app协议(android开发人员提供)
window.setTimeout(function() {
window.location.href = "http://www.treeic.com/clients/chuiniu-29-1.3.3-20180124.apk";//android app下载地址
}, 2000)
}
};
</script>

0 个评论

要回复文章请先登录注册