2012-07-03 39 views
1

我想检查客户端打开的页面是否使用iOS6。用户代理检查ios6

var startIndex = navigator.userAgent.search(/OS/i) + 2; 
    var endIndex = navigator.userAgent.search(/like/i); 
    var iOSVersion = parseInt(navigator.userAgent.substr(startIndex,endIndex - startIndex).trim()); 
    this.iOSVersion = true; 

    if(!isNaN(iOSVersion)){ 
     this.iOSVersion = iOSVersion; 
    } 
    else if(Ext.is.Desktop){ 
     this.iOSVersion = true; 
    } 

上述代码适用于所有版本的浏览器。

但是在iOS6中使用它,它显示为iOS5。搜索同样的事情,但我没有找到解决方案。可能是我还没有完成搜索,并排搜索,并希望如果有人遇到过这个问题。

任何建议或更新?

回答

2

这应该在iOS 6的转基因种子现在的工作和下面的正则表达式可以与iOS6的检测都用iPhone/iPad:

/OS(\ w +)喜欢Mac OS/i.exec(navigator.userAgent的)

+0

谢谢,上面我给出的问题实际上现在也适用于io6检测。 –