js判斷本地是否安裝app
<script language="javascript"> document.getElementById('openApp').onclick = function(e){ if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) { var loadDateTime = new Date(); window.setTimeout(function() { var timeOutDateTime = new Date(); if(timeOutDateTime - loadDateTime < 5000) { window.location = "https://itunes.apple.com/cn/app/id477927812"; } else { window.close(); } }, 25); window.location = "weixin:// "; } else if(navigator.userAgent.match(/android/i)) { var state = null; try { state = window.open("weixin://"); } catch(e) {} if(state) { window.close(); } else { window.location = "http://dldir1.qq.com/weixin/android/weixin656android1020.apk"; } } } </script>
判斷本地是否安裝了某個app,前提條件:你得知道你的APP對應的打開協議,如貼吧APP,協議為:com.baidu.tieba:// ,微信的:weixin:// ,等等。app下載鏈接可以到app官網找,然后用瀏覽器打開就行。