首页 > 移动平台 > 详细

Detecting iOS

时间:2015-09-15 12:40:32      阅读:237      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/sban/p/4809739.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!