Gigazelle Gigazelle -3 years ago 113
Javascript Question

How can I get iOS device version using JavaScript?

Is there a way to obtain an iOS device version (as opposed to OS version) using JavaScript or another browser-based language? For example; iPhone5, iPhone 4S, iPad 3, etc.

I have not been able to locate this information in

navigator.userAgent
(or any methods of
navigator
), as it only reports the OS version (and not the device used). For example, an iPhone5 running 6.1.3 has this user-agent:

"Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.25"


And an iPhone4 running 6.1.3:

"Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.25"


The best I've been able to find is by using the
screen.width
and
screen.height
, as this would at least let me differentiate between iPhone5, iPhone4, and previous generations.

Answer Source

You can't. You can find iPhone or iPad, and what version of iOS the device is running, but you can't find a model name such as iPhone 4.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download