Detect iPhone Version using jQuery
Related Post:
To detect iPhone version, check the height of the iPhone. As you know the screen resolution of all iPhone's version till iPhone 3GS is 320×480, for iPhone 4 its 640×960 and for iPhone 5 its 640×1136.
So by calculating height, you can conclude whether it is iPhone 4 or iPhone 5. As all the below version of iPhone4 have same resolution, so it is not possible to find out whether it is iPhone 3 or 3GS or 2 (But I guess it is not important as well as people have switched to new iPhones).
Note: Before you execute this code, please include code for detecting iPhone.
$(document).ready(function(){ var iHeight = window.screen.height; if(iHeight <= 480) { console.log('iPhone 2 or iPhone 3 or iPhone 3GS'); } else if(iHeight > 480 && iHeight <=960) { console.log('iPhone 4'); } else if(iHeight > 960) { console.log('iPhone 5'); } });
If you know any other method, then please share with us.
Feel free to contact me for any help related to jQuery, I will gladly help you.