使用JavaScript检测小于5的iOS版本 [英] Detect iOS version less than 5 with JavaScript
本文介绍了使用JavaScript检测小于5的iOS版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这与位置的修复有关:在旧版本的iOS中修复。但是,如果安装了iOS5或更高版本,修复程序会破坏页面。
This is related to the "fix" for position:fixed in older versions of iOS. However, if iOS5 or greater is installed, the fix breaks the page.
我知道如何检测iOS 5: navigator.userAgent.match(/ OS 5_ \d,如Mac OS X / i)
但是当iOS6最终出现时,它不适用于iOS6,甚至iOS 5.0.1 2位数版本。
I know how to detect iOS 5: navigator.userAgent.match(/OS 5_\d like Mac OS X/i)
but that won't work for iOS6 when it eventually comes around, or even iOS 5.0.1, only a 2 digit version.
所以这就是我的atm。
So this is what I have atm.
$(document).bind("scroll", function() {
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
if (navigator.userAgent.match(/OS 5_\d like Mac OS X/i)) {
}
else {
changeFooterPosition();
}
});
推荐答案
这段代码可用于确定任何版本iOS 2.0及更高版本。
This snippet of code can be used to determine any version of iOS 2.0 and later.
function iOSversion() {
if (/iP(hone|od|ad)/.test(navigator.platform)) {
// supports iOS 2.0 and later: <http://bit.ly/TJjs1V>
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
return [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)];
}
}
ver = iOSversion();
if (ver[0] >= 5) {
alert('This is running iOS 5 or later.');
}
这篇关于使用JavaScript检测小于5的iOS版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文