在html页面中js判断app是否安装并直接打开
2015-11-25 09:29
786 查看
<script type="text/javascript"> document.getElementById('openApp').onclick = function(e){ // 通过iframe的方式试图打开APP,如果能正常打开,会直接切换到APP,并自动阻止a标签的默认行为 // 否则打开a标签的href链接 var agent = navigator.userAgent.toLowerCase() ; var version; if(agent.indexOf("like mac os x") > 0){ //ios var regStr_saf = /os [\d._]*/gi ; var verinfo = agent.match(regStr_saf) ; version = (verinfo+"").replace(/[^0-9|_.]/ig,"").replace(/_/ig,"."); } var version_str = version+""; if(version_str != "undefined" && version_str.length >0){ version=version.substring(0,1); if(version > 8){ location.href = 'com.ywwy.MaiDian3://'+"<?=$shop['id']?>"; window.setTimeout(function(){ location.href = 'https://itunes.apple.com/cn/app/id1052060244'; },300) } else{ var ifr = document.createElement('iframe'); ifr.src = 'com.ywwy.MaiDian3://'+"<?=$shop['id']?>"; ifr.style.display = 'none'; document.body.appendChild(ifr); window.setTimeout(function(){ location.href = 'https://itunes.apple.com/cn/app/id1052060244'; },300) } } }; </script>
相关文章推荐
- 移动端报表使用教程-如何添加服务器
- GitHub iOS-Top 100 简介
- Android proguard 详解
- CF Round#333 Div2 B. Approximating a Constant Range
- Android L APP 如何获取sys file system 中节点的写权限
- 在网页中能正常显示的页面,在手机端出现问题?
- Android 粘贴板(ClipboardManager)
- Android 三种播放视频的方式
- Android实用小技巧(动态更新)
- HTML5跨平台移动端应用开发
- iOS开发--JSON
- android动态添加View
- SpringMVC中HandlerMapping的三种配置方式
- Android Log工具之Luffy
- Xcode 历史版本官方下载地址 Xcode6 Xcode7
- Android 数据存储方式(一.文件+内部外部存储吐血详解)
- iOS完整学习路线图
- Android 下载线程的编写
- Android中图片的三级缓存
- Android and MJPEG