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常用命令汇总(渐更)

    后台启动jar nohup java -jar xxxxx.jar > xxxx.out 2>&1 & 封禁ip iptables -I INPUT -s 200.194. ...

  2. shiro web环境初始化过程

    在web工程中使用shiro的时候需要配置一个shiro的listenser(EnvironmentLoaderListener)和一个shiro的filter(ShiroFilter). liste ...

  3. 淘宝H5移动端解决方案

    详细:http://www.w3cplus.com/mobile/lib-flexible-for-html5-layout.html ; (function(win, lib) { var doc ...

  4. JAVA中日期格式转换各个字母代表含义

    G  Era 标志符  Text  AD  y  年  Year  1996; 96  M  年中的月份  Month  July; Jul; 07  w  年中的周数  Number  27  W  ...

  5. css高度已知,左右定宽,中间自适应三栏布局

    css高度已知,左右定宽,中间自适应三栏布局: <!DOCTYPE html> <html lang="en"> <head> <meta ...

  6. Cocos2d-x v3.1 坐标系统(五)

    Cocos2d-x v3.1 坐标系统(五) 为了能够更好的布局以及了解对象所在的位置,我们必须对Cocos2d-x中的坐标有详细的了解,本篇文章主要就是了解Cocos中用到的坐标系统.学过数学的人都 ...

  7. 【Quartus警告】created implicit net for XXX.

    [警告内容]Warning (10236): Verilog HDL Implicit Net warning at forward_replace.v(16): created implicit n ...

  8. LAMP stack-5.6.22 (OpenLogic CentOS 7.2)

    平台: CentOS 类型: 虚拟机镜像 软件包: apache2.4.20 mysql5.6.30 php5.6.22 apache application server basic softwar ...

  9. PRD、MRD、BRD的含义

    一.PRD的含义 英文简称,PRD(Product Requirement Document),PRD文档中文意思是:产品需求文档. PRD文档是产品项目由“概念化”阶段进入到“图纸化”阶段的最主要的 ...

  10. 爬虫系统-日志、初始化url

    1.日志log4j 1.1.DEBUG:debug级别 1.2.stdout:输出到控制台 1.3.D:输出到文件 log4j.rootLogger=DEBUG, stdout,D #Console ...