js唤醒手机APP
if (navigator.userAgent.match(/android/i)) {
// 通过iframe的方式试图打开APP,如果能正常打开,会直接切换到APP,并自动阻止a标签的默认行为
// 否则打开a标签的href链接
var isInstalled;
//下面是安卓端APP接口调用的地址,自己根据情况去修改
var ifrSrc = 'cartooncomicsshowtwo://platformapi/startApp? type=0&id=${com.id}&phone_num=${com.phone_num}';
var ifr = document.createElement('iframe');
ifr.src = ifrSrc;
ifr.style.display = 'none';
ifr.onload = function() {
// alert('Is installed.');
isInstalled = true;
alert(isInstalled);
document.getElementById('openApp0').click();};
ifr.onerror = function() {
// alert('May be not installed.');
isInstalled = false;
alert(isInstalled);
}
document.body.appendChild(ifr);
setTimeout(function() {
document.body.removeChild(ifr);
},1000);
}
//ios判断
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
//Animation://com.yz.animation
var isInstalled;
//var gz = '{"comName":"${com.short_name}","comID":"${com.id}","comPhoneNum":"${com.phone_num}","type":"0"}';
//var jsongz =JSON.parse(gz);
//下面是IOS调用的地址,自己根据情况去修改
var ifrSrc = 'Animation://?comName=${com.short_name}&comID=${com.id}&comPhoneNum=${com.phone_num}&type=0';var ifr = document.createElement('iframe');
ifr.src = ifrSrc;
ifr.style.display = 'none';
ifr.onload = function() {
// alert('Is installed.');
isInstalled = true;
alert(isInstalled);
document.getElementById('openApp1').click();};
ifr.onerror = function() {
// alert('May be not installed.');
isInstalled = false;
alert(isInstalled);
}
document.body.appendChild(ifr);
setTimeout(function() {
document.body.removeChild(ifr);
},1000);
}
}
下面这个IOS可用,安卓不可用
<meta name='apple-itunes-app' content='app-id=477927812'>
- <!-- a标签的链接,设置为对应的下载链接;点击打开的动作,在click事件中注册 -->
- <a href="https://itunes.apple.com/cn/app/id477927812" id="openApp">贴吧客户端</a>
- <script type="text/javascript">
- document.getElementById('openApp').onclick = function(e){
- // 通过iframe的方式试图打开APP,如果能正常打开,会直接切换到APP,并自动阻止a标签的默认行为
- // 否则打开a标签的href链接
- var ifr = document.createElement('iframe');
- ifr.src = 'com.baidu.tieba://';
- ifr.style.display = 'none';
- document.body.appendChild(ifr);
- window.setTimeout(function(){
- document.body.removeChild(ifr);
- },3000)
- };
- </script>
js唤醒手机APP的更多相关文章
- 使用JS调用手机本地摄像头或者相册图片识别二维码/条形码
接着昨天的需求,不过这次不依赖微信,使用纯js唤醒手机本地摄像头或者选择手机相册图片,识别其中的二维码或者是条形码.昨天,我使用微信扫一扫识别,效果超棒的.不过如果依赖微信的话,又怎么实现呢,这里介绍 ...
- 微信公众号 唤醒手机导航APP 一看就懂 复制即用
公司自研发框架,基本上没啥看不懂的 基本都是直接复制用就好了!希望能帮助到需要的朋友! 新建俩个同级文件用来保存 jsapi_ticket 和 access_token的文件 命名:jsapi_tic ...
- 手机网页唤醒支付宝APP发送加好友验证
手机网页唤醒支付宝APP发送加好友验证 <!DOCTYPE html> <html> <head> <meta charset="utf-8&quo ...
- 手机web站点和手机app 技术选型的困惑于思考
今年一直在关注移动端技术的发展,自己也用博客园的rss接口玩了半年,关于技术选型的困惑和大家说说 一 趋势 随着手机硬件不断的升级,外加4g牌照的发放,不出2年时间移动端web站点和手机app一定会进 ...
- HTML5手机APP开发入门(1)
HTML5手机APP开发入门(1) 开发框架 Ionicframework V2 + Angular 2 具体内容可以参考一下网站 http://ionicframework.net/ http:// ...
- 会写网页 就会写手机APP -- Hybrid Mobile Apps for ASP.NET Developers
您好,这篇文章是我的BLOG发出,原始出处在此: 会写网页 就会写手机APP -- Hybrid Mobile Apps for ASP.NET Developers http://www.dotbl ...
- js判断手机浏览器操作系统和微信浏览器的方法
做手机端的前端开发,少不了对手机平台的判断.如,对于app下载,就要判断在Android平台下就显示Android下载提示:在iOS平台下就显示iOS下载提示. 今天就为大家介绍一下用js判断手机客户 ...
- js获取手机型号和手机操作系统版本号
1.js 判断IOS版本号 先来观察 iOS 的 User-Agent 串: iPhone 4.3.2 系统:Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 l ...
- 手机APP有三类:原生APP,WebAPP,HybridApp
搭建 AngularJS+Ionic+Cordova 开发环境并运行一个demo 目前的手机APP有三类:原生APP,WebAPP,HybridApp:HybridApp结合了前两类APP各自的优点, ...
随机推荐
- java集合类-集合框架体系
集合框架体系 集合框架体系是由Collection.Map和 Iterator(迭代器) 实线边框的是实现类,折线边框的是抽象类,而点线边框的是接口 Collection体系 Set接口:元素无序且不 ...
- scrapy框架之log日志
scrapy中的debug信息 在scrapy中设置log 1.在settings中设置log级别,在settings.py中添加一行: Scrapy提供5层logging级别: CRITICAL - ...
- c++ demo code
/* //多继承 #include <iostream> using namespace std; class Sofa { public: Sofa(); ~Sofa(); void s ...
- Spring Cloud Eureka(七):DiscoveryClient 源码分析
1.本节概要 上一节文章主要介绍了Eureka Client 的服务注册的流程,没有对服务治理进行介绍,本文目的就是从源码角度来学习服务实例的治理机制,主要包括以下内容: 服务注册(register) ...
- JQuery 行内编辑(即点即改)
行内编辑 下面是详细的代码: <style> .dian { cursor: pointer; } </style> //这个让鼠标 移动到 span上 的时候 是一个小手 & ...
- elasticsearch _source
默认地,Elasticsearch 在 _source 字段存储代表文档体的JSON字符串.和所有被存储的字段一样, _source 字段在被写入磁盘之前先会被压缩.这个字段的存储几乎总是我们想要的, ...
- nginx 配置 nodejs 反向代理
upstream my_nodejs_upstream { server ; keepalive ; } server { listen ; server_name www.my-website.co ...
- 如何使用纯js实现一个带有灰色半透明背景的弹出框
原文如何使用纯js实现一个带有灰色半透明背景的弹出框 // 加入透明背景 var body = document.body;var backgroundDiv = document.createEle ...
- nodejs 服务器模拟异常状态码429,以及前端vue axios捕获状态码
nodejs 服务端发送429状态: extendInfo (req, res) { res.status(429).json('Too many requests, please try again ...
- DataTable 转换为List
注意table 列的参数类型,若不为string 需要详细声明 如 typeof(Int32) public static IList<T> Convert ...