Detecting iOS

I am not a fan of User Agent sniffing, but here is how you would do it:

var iOS = /iPad|iPhone|iPod/.test(navigator.platform);

Another way, relying on the userAgent:

var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;

iOS will be either true or false

Why not MSStream

Microsoft injected the word iPhone in IE11's userAgent in order to try and fool Gmail somehow. Therefore we need to exclude it. More info about this here and here.

Below is IE11's updated userAgent (Internet Explorer for Windows Phone 8.1 Update):

Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 930) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537

Detecting iOS的更多相关文章

  1. phonegap + xcode5.0.2 配置开发环境

    phonegap官网:  http://phonegap.com/ 第一部:安装nodejs 安装地址:http://nodejs.org/ 安装phoneGap 官网下载http://phonega ...

  2. Mac安装PhoneGap3

    Mac安装PhoneGap3第一步需要安装NodeJS,在Mac下有一个.pkg安装包(Mac OS X Installer (.pkg),下载下来一路点击就可以安装成功了.在Terminal控制台输 ...

  3. JavaScript_JS判断客户端是否是iOS或者Android

    通过判断浏览器的userAgent,用正则来判断是否是ios和Android客户端.代码如下: <script type="text/javascript"> var ...

  4. IOS开发--UI进阶之iCarousel学习(待翻译)

    前言:先展示这个会被多个项目用到的开源的轮播器的其中一个动画效果: 更多的效果请到github原网址查看:https://github.com/nicklockwood/iCarousel 源码也可以 ...

  5. ios上uiwebview的一些实用技巧

    前几个星期接到公司一个项目,要用webview在客户端上播视频,作为一个前端实习生,这种需求真是蛋疼……一不知webview是何方神圣,二不知咋调试…… 下面就是蛋疼的开始:  寻找调试工具:好,非w ...

  6. 【IOS笔记】Event Delivery: The Responder Chain

    Event Delivery: The Responder Chain  事件分发--响应链 When you design your app, it’s likely that you want t ...

  7. iOS 解析手势识别(Gesture Recognizers)

    一.Gesture Recognizers Gesture Recognizers是在iOS3.2引入的,可以用来识别手势.简化定制视图事件处理的对象.Gesture Recognizers的基类为U ...

  8. IOS 逆向工程之砸壳

    在<iOS应用逆向工程>4.6.2节中,我们曾推荐使用iPhoneCake源的AppCrackr 1.7版给App砸壳.这种方式简单粗暴,省时省力,但正是因为它过于方便有木有,导致几乎所有 ...

  9. [转]About the security content of iOS 8

    Source:http://support.apple.com/kb/HT6441 For the protection of our customers, Apple does not disclo ...

随机推荐

  1. Linux软件相关记录

    Pidgin+lw-web的聊天记录的文件对应的目录为.purple/logs/webqq/你的QQ号码/,进入之后有选择的删除. mkdir -p 递归创建目录:pwd 显示当前目录:cd .. 回 ...

  2. js 数组对象去重

    let hash = {}; let config = [ { name: 2, state: true, output: 'Y'}, { name: 3, state: true, output: ...

  3. 从零开始的全栈工程师——js篇2.15(offsetLeft)

    元素的属性 Div.attributes 是所有标签属性构成的数据集合 Div.classList 是所有class名构成的数组集合 在classList的原型链上看以看到add()和remove() ...

  4. 从零开始的全栈工程师——js篇2.6

    函数 Var 是js的关键字,用于声明变量,声明在内存模块完成,定义(=)是在执行模块完成. Var可以在内存模块提前(js代码执行前)完成所以有变量提升这个功能. 因为a没有带var,所以不存在变量 ...

  5. axios拦截器+mockjs

    //main.js中 //引入你mock.js文件 require('./mock.js') //封装api请求 //src/axios/api.js import axios from 'axios ...

  6. intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)用法

    如果已经启动了四个Activity:A,B,C和D.在D Activity里,我们要跳到B Activity,同时希望C finish掉,可以在startActivity(intent)里的inten ...

  7. python any all函数

    a = [0, 0, 0, 0] b = [0, 0, 0, 1] c = [1, 1, 1, 1] >>> any(a) False >>> any(b) Tru ...

  8. ASP.NET中 前后台方法的相互调用

    后台调用前台js方法: this.Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "ShowM ...

  9. Metasploitable渗透测试实战——Windows漏洞 MS08-067复现

    Ms08-067 攻防环境: 攻击机:kali     ip:198.168.12.212 靶机:Window XP 未打过ms08-067补丁  ip:198.168.12.209

  10. pta 编程题8 Tree Traversals Again

    其它pta数据结构编程题请参见:pta 这次的作业考察的是树的遍历. 题目的输入通过栈的pop给出了树的中序遍历的顺序.根据push和pop的顺序构造树的方法为:定义一个变量father来确定父节点, ...