1

I come across bugs with fixed positionning on iOs (fixed menu on bottom, coming on the middle of screen when the keyboard comes up).

The thing is, this bug only happens on iOs 6.1.4. So the fix i've just done works for iOs 6.1.4 (this one : http://dansajin.com/2012/12/07/fix-position-fixed/), but makes the menu coming to the middle on the screen on iOs 6.1.3...

Is there a way to detect the current version of iOs in JS ?

enguerranws
  • 7,273
  • 7
  • 40
  • 83
  • 1
    [this could help](http://stackoverflow.com/questions/8348139/detect-ios-version-less-than-5-with-javascript) – Pete Nov 29 '13 at 15:20

2 Answers2

2

Have you tried using console.log(navigator); to grab information regarding the browsing machine?

navigator.userAgent or navigator.platform will provide you with the basis for what you need, that said I'm not so sure you'll be able to track it down to such a specific degree.

You can also try this snippet of code:

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 (/(iPad|iPhone|iPod)/g.test( navigator.userAgent ) && ver[0] == 6 && ver[1] ==1 && ver[2]==3) {
  alert('This is running iOS 6.1.3 or later.');
}

Adapted from here

My recommendation would be always to attempt to fix the underlying issue rather than implement a workaround, however I appreciate this can sometimes be impractical.

Community
  • 1
  • 1
SW4
  • 65,094
  • 17
  • 122
  • 131
1

According to this post the iOS version (above 2.0) can be found with:

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] === 6.14) {
  alert('This is running iOS 6.14.');
}
Community
  • 1
  • 1
Pippin
  • 996
  • 5
  • 15