ios利用scheme拉起app

作者: shaneZhang 分类: 互联网技术 发布时间: 2015-04-29 12:50
<html>   
    <head>   
        <meta name="viewport" content="width=device-width" />   
    </head>   
    <body>   
        <h2><a id="applink1" href="timeradio://timeradio">Open scheme(timeradio) defined in iPhone with parameters </a></h2>   
        <h2><a id="applink2" href="unknown://nowhere">open unknown with fallback to appstore</a></h2>   
        <p><i>Only works on iPhone!</i></p>      

        <script type="text/javascript">   
            // To avoid the "protocol not supported" alert, fail must open another app.  
            var appstore = "itms://itunes.apple.com/cn/app/shi-guang-dian-tai/id734232598?mt=8";  
            function applink(fail){  
                return function(){  
                    var clickedAt = +new Date;  
                    // During tests on 3g/3gs this timeout fires immediately if less than 500ms.  
                    setTimeout(function(){  
                              // To avoid failing on return to MobileSafari, ensure freshness!  
                              if (+new Date - clickedAt < 2000){  
                              window.location = fail;  
                              }  
                              }, 500);      
                };  
            }  
            document.getElementById("applink1").onclick = applink(appstore);  
            document.getElementById("applink2").onclick = applink(appstore);  
            </script>   
    </body>   
</html>

如果觉得我的文章对您有用,请随意打赏。如果有其他问题请联系博主QQ(909491009)或者下方留言!

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注