Is there any generic way to detect iOS6 device using feature detection.
-
All the "tall" devices (currently iPhone 5 and 5th-gen Touch) have iOS6, but that is of course only a (still small) part of it. What are you going to do different depending on the iOS version? Maybe there is another way to detect just the relevant piece of information for that? – Thilo Dec 10 '12 at 11:54
-
you might be able to get it from `navigator.userAgent` – bart s Dec 10 '12 at 11:57
-
I just wanted to detect iOS6 and I felt feature detection would be better than using userAgent. – Exception Dec 10 '12 at 11:58
2 Answers
You could check the FileReader
API, but of course this'll match many modern desktop browsers, too (I'm not sure if that's going to cause you some problems, but I doubt it):
var iOS6 = false;
if(window.FileReader)
{
iOS6 = true;
}

- 52,573
- 26
- 113
- 168
-
This seems better than creating an element and checking its attributes. It could be simply written `iOS6 = !!window.FileReader;` – Jake Mar 05 '13 at 21:42
-
I think the best way is always to parse the user agent string but you can detect the Safari version introduced with iOS 6 using a previously unsupported feature (see this article for a more complete list, I'll provide just one example).
Basically you have to mimic the same technique used by modernizr, with this piece of code you'll check if the <input>
type file
is supported, if it is then you're running on Safari with iOS 6 or greater. Of course just using features you can't be sure that the user isn't using another browser (that's why I prefer the user agent string if you have to detect the OS version). For a comparison see this post here on SO.
function isNewVersion() {
var elem = document.createElement("input");
elem.setAttribute("type", "file");
return elem.type !== "text";
}

- 1
- 1

- 65,416
- 20
- 137
- 208