Detect iPhone Version using jQuery

In this post, find jQuery/JavaScript code to detect iPhone version. There is no direct way to find out version and in fact the User agent string also doesn't have any information about iPhone version. The User Agent string have details about OS version, but not the iPhone version.

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.

   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.

Responsive Menu
Add more content here...