H5打开APP
let iosDownload = '******', // 如果打开scheme失效的app下载地址 andDownload = '*****'; let u = navigator.userAgent; let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 // 需要打开的app scheme 地址 window.location.href = isAndroid ? '****' : '****'; // 尝试打开 scheme // 设置3秒的定时下载任务,3秒之后下载app setTimeout(function () { let hidden = window.document.hidden || window.document.mozHidden || window.document.msHidden || window.document.webkitHidden; if (typeof hidden !== "undefined" && hidden === true) { return; } if (isAndroid) { window.location.href = andDownload; } if (isIOS) { window.location.href = iosDownload; } }, 3000);