js判断手机端操作系统的两种方法
//判断手机端操作系统(Andorid/IOS),并自动跳转相应下载界面
androidURL ="http://xxx/xxx.apk";
var browser = {
versions: function() {
var u = navigator.userAgent,
app = navigator.appVersion;
return {
android: u.indexOf("Android") > -1 || u.indexOf("Linux") >-1,
iPhone: u.indexOf("iPhone") > -1 ,
iPad: u.indexOf("iPad") >-1,
iPod: u.indexOf("iPod") > -1,
};
} (),
language: (navigator.browserLanguage || navigator.language).toLowerCase()
}
if (browser.versions.iPhone||browser.versions.iPad||browser.versions.iPod)
{
//如果是ios系統,直接跳轉至appstore該應用首頁,傳遞参數为該應用在appstroe的id號
window.location.href="itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=123456";
}
else if(browser.versions.android)
{
window.location.href = androidURL;
}
/* //第二种方法
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
//alert(navigator.userAgent);
window.location.href ="iPhone.html";
} else if (/(Android)/i.test(navigator.userAgent)) {
//alert(navigator.userAgent);
window.location.href ="Android.html";
} else {
window.location.href ="pc.html";
};
*/
js判断手机端操作系统的两种方法的更多相关文章
- js判断手机端操作系统(Andorid/IOS)
非常实用的js判断手机端操作系统(Andorid/IOS),并自动跳转相应下载界面 androidURL = "http://xxx/xxx.apk"; var browser = ...
- JS动态创建元素(两种方法)
前言 创建元素有两种方法 1)将需要创建的元素,以字符串的形式拼接:找到父级元素,直接对父级元素的innnerHTML进行赋值. 2)使用Document.Element对象自带的一些函数,来实现动态 ...
- 原生js判断手机端页面滚动停止
var topValue = 0,// 上次滚动条到顶部的距离 interval = null;// 定时器 contactsList = document.getElementById(" ...
- js判断手机端
if (window.location.toString().indexOf('pref=padindex') != -1) { } else { if (/AppleWebKit.*Mobile/i ...
- js笔记(3)--js实现数组转置(两种方法)
js实现数组转置 第一种方法: <script> window.onload=function(){ var array1=[[11,22,33,333],[4 ...
- JS取地址栏参数的两种方法
第一种方法: function GetQueryString(name){ var reg = new RegExp("(^|&)"+ name +"=([^&a ...
- iOS: JS和Native交互的两种方法
背景: UIWebView: iOS 用来展示 web 端内容的控件. 1. 核心方法: - (NSString*)stringByEvaluatingJavaScriptFromString:(NS ...
- js访问对象属性的两种方法
var obj={name:'fuuf',age:19} 第一种,用.访问 obj.name 第二种 用[]访问 obj['name'] //此时name是字符串,要加引号 注意事项 使用第二种方法 ...
- 【微信小程序】在js中导入第三方js或自己写的js,使用外部js中的function的两种方法 import和require的区别使用方法 【外加:使用第三方js导出的默认function的调用方法】
如下 定义了一个外部js文件,其中有一个function import lunaCommon from '../lunaCommon.js'; var ctx = wx.getStorageSync( ...
随机推荐
- Air File.load加载问题
不要用File.load同时加载多个文件,有时会引起程序崩溃. 在需要同时加载多个文件时,要一个一个排队加载,等到上一个加载完成再加载下一个. 也可以设定一个static的File,加载前先File. ...
- Spring中的AOP(五)——定义切入点和切入点指示符
定义切入点 在前文(点击查看)中使用到的AdviceTest类中同一个切点(即* com.abc.service.*.advice*(..)匹配的连接点)却重复定义了多次,这显然不符合软件设计的原则, ...
- was not registered for synchronization because synchronization is not active
报SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7862f70e] was not registered for s ...
- python报OperationalError: (1366, "Incorrect string value..."的问题解决
一.环境及问题描述 1. 环境 操作系统:win10,64bit. python版本:2.7.15 mysql版本:5.7.23 2. 问题描述 使用python从某个数据文件读取数据,处理后,用My ...
- mysql资源总结
MySQL查询语句大全集锦 http://www.jb51.net/article/85889.htm linux下mysql命令大全 http://www.cnblogs.com/mfryf/arc ...
- [转]go中的main函数和init函数
Go里面有两个保留的函数:init函数(能够应用于所有的package)和main函数(只能应用于package main).这两个函数在定义时不能有任何的参数和返回值.虽然一个package里面可以 ...
- asp.net core 1.1 + mysqlsugar + y-ui Demo
最近研究下asp.net core 此源码架构 : .net core mvc 简单三层 依赖注入(.net core自带) mysql + mysqlsugar +sqlsugarcore 需要修 ...
- git pull --rebase的使用
原文:http://www.cnblogs.com/kevingrace/p/5896706.html 使用下面的关系区别这两个操作:git pull = git fetch + git mergeg ...
- python的return
关于python的return用法,在stackoverflow里的问题: Python — return, return None, and no return at all Consider th ...
- string 转换为枚举对应的值
public static Object Parse(Type enumType,string value) 例如:(Colors)Enum.Parse(typeof(Colors), "R ...