JS判断手机端是否安装某应用
方法一(网页上判断)
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 = "要跳转的页面URL"; } else { window.close(); } }, 25); } else if (navigator.userAgent.match(/android/i)) { var state = null; try { } catch(e) {} if (state) { window.close(); } else { window.location = "要跳转的页面URL"; } }方法二
function testApp(url) { var timeout, t = 1000, hasApp = true; setTimeout(function () { if (hasApp) { alert('安装了app'); } else { alert('未安装app'); } document.body.removeChild(ifr); }, 2000) var t1 = Date.now(); var ifr = document.createElement("iframe"); ifr.setAttribute('src', url); ifr.setAttribute('style', 'display:none'); document.body.appendChild(ifr); timeout = setTimeout(function () { var t2 = Date.now(); if (!t1 || t2 - t1 < t + 100) { hasApp = false; } }, t); } 方法三(APP里判断)
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 if(isAndroid){ function android(){ window.setTimeout(function(){ },2000); };if(isiOS){ function ios(){ var ifr = document.createElement("iframe"); ifr.style.display = "none"; document.body.appendChild(ifr); window.setTimeout(function(){ document.body.removeChild(ifr); },2000) };}JS判断手机端是否安装某应用的更多相关文章
- js判断手机端操作系统(Andorid/IOS)
非常实用的js判断手机端操作系统(Andorid/IOS),并自动跳转相应下载界面 androidURL = "http://xxx/xxx.apk"; var browser = ...
- js判断手机端操作系统的两种方法
//判断手机端操作系统(Andorid/IOS),并自动跳转相应下载界面 androidURL ="http://xxx/xxx.apk"; var browser = { ver ...
- js判断手机端
if (window.location.toString().indexOf('pref=padindex') != -1) { } else { if (/AppleWebKit.*Mobile/i ...
- 原生js判断手机端页面滚动停止
var topValue = 0,// 上次滚动条到顶部的距离 interval = null;// 定时器 contactsList = document.getElementById(" ...
- js判断手机端操作系统(Andorid/IOS),并自动为链接添加相应下载地址
<script type="text/javascript"> $(document).ready(function(e) { var u = navigator.us ...
- js判断手机端Android手机还是iPhone手机
/*判断当前设备是平板.安卓.苹果设备*/ <script type="text/javascript"> function fBrowserRedirect(){ v ...
- js判断手机端(Android手机还是iPhone手机)
/** * [isMobile 判断平台] * @param test: 0:iPhone 1:Android */ function ismobile(test){ var u = navigato ...
- JS判断手机端和PC端自动跳转
<script type="text/javascript"> function browserRedirect() { var sUserAgent ...
- js判断手机端和pc端
var browser = { versions: function() { var u = navigator.userAgent, app = navigator.appVersion; retu ...
随机推荐
- hibernate一级缓存和快照
摘自网络: Hibernate中的一级缓存的底层是以Map形式存在的,key是主键,value是对象,所以它的泛型为Map<Serializable,Object>,key的泛型为串行化是 ...
- 前后端如何保持长连接?---websocket
1. pc端的应用,一般会采用前端定时请求后台; 2. app定时去访问后台的话,对用户来说并不友好,会消耗大量的流量,移动端最好的方式就是后台主动向app推送信息; 3. H5提供了一种比较好的方式 ...
- java_GC
垃圾回收1 内存分配 垃圾回收 调用垃圾回收器 对象终结 调用垃圾回收器 System.gc()和Runtime.getRuntime(). ...
- Property ‘password’ threw Exception
问题描述: Maven项目在tomcat启动的时候总是报Propety 'password' threw exception异常时,说明password不对,但核对之后没有问题 解决方案: 核对pas ...
- java中的成员变量、静态变量与局部变量
java中的变量分为成员变量(又叫实例变量).静态变量和局部变量. 1.成员变量 1.1 成员变量(实例变量)是在类中定义的非static修饰的变量,可以不用赋初始值,不同的数据类型有默认的初始值. ...
- 对象克隆(C# 快速高效率复制对象另一种方式 表达式树转)
1.需求 在代码中经常会遇到需要把对象复制一遍,或者把属性名相同的值复制一遍. 比如: public class Student { public int Id { get; set; } publi ...
- jmeter配置脚本录制进行抓包并快速分析、定位接口问题
对于测试人员.开发人员来说,善用抓包工具确实是快速分析和定位问题的一大必备神技,现将配置过程记录如下: 1.打开jmeter后,首先添加一个线程组: 2.线程组可以重新命名按项目名称分类 3.然后在工 ...
- [转][C#]压缩解压
{ internal static class Compressor { public static Stream Decompress(Stream source, bool bidiStream) ...
- C++Primer第五版——习题答案详解(十)
习题答案目录:https://www.cnblogs.com/Mered1th/p/10485695.html 第11章 关联容器 练习11.3 #include<iostream> #i ...
- ado.net调用返回多结果集的存储过程