您现在的位置是:网站首页>前端技术>HTML5教程HTML5教程
H5跳转APPJS代码
神夜2019-09-30 10:30:48【HTML5教程】3988人已围观文章来源:神夜个人博客
简介H5跳转APPJS代码
H5跳转APPJS代码
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>跳转APPtitle>
head>
<body onLoad="panduan()">
body>
html>
<script>
function getUrlParam (name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
var r = window.location.search.substr(1).match(reg);
if (r != null) return decodeURIComponent(r[2]); return "";
}
function panduan () {
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
var shopId = getUrlParam('shopId');
if(isAndroid){
var ifr = document.createElement("iframe");
ifr.src = "android://com.xxxx.bearshoptohome/open?shopId=" + shopId; /***打开app的协议,有android同事提供***/
ifr.style.display = "none";
document.body.appendChild(ifr);
window.setTimeout(function(){
document.body.removeChild(ifr);
window.location.href = "https://sj.qq.com/myapp/detail.htm?apkName=com.xxxx.bearshoptohome"; /***下载app的地址***/
},500)
}else{
var ifr = document.createElement("iframe");
ifr.src = "bearbuyer://"; /***打开app的协议,有ios同事提供***/
ifr.style.display = "none";
document.body.appendChild(ifr);
window.setTimeout(function(){
document.body.removeChild(ifr);
window.location.href = "https://itunes.apple.com/cn/app/id555555?mt=8"; /***下载app的地址***/
},500)
}
}
script>
本栏推荐
猜你喜欢
站点信息
- 建站时间:2017-10-24
- 网站程序:Hsycms 3.0
- 文章统计:511条
- 微信公众号:扫描二维码,关注我们