实现短信中链接打开app,已安装直接打开,未安装跳转到下载页面

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>this's a demo</title>
    <meta name='apple-itunes-app' content='app-id=这里填写apple ID'> //这里要填写一下apple ID 
</head>
<body>
    <a href="#" id="openApp"><h1>测试短信启动app</h1></a>
</body>
</html>
<script type="text/javascript">	
    document.getElementById('openApp').onclick = function(e){
        if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i))
           {
            window.location.href = "ios 启动app的链接";//ios app协议  找前端的要
            window.setTimeout(function() {
                window.location.href = "下载页面";
            }, 500)
           }
        if(navigator.userAgent.match(/android/i))
        {
            window.location.href = "android 启动app的链接";//android  app协议  链接找前端的要
            window.setTimeout(function() {
                window.location.href = "下载页面";
            }, 500)    
        }
    };
</script>

参考文章:https://www.cnblogs.com/h–d/p/5846675.html

posted @ 2019-11-06 17:29  马大哈小果果  阅读(803)  评论(0)    收藏  举报