Forked from jordandobson/iphone-ipad-detect-version.js
Created
April 14, 2010 00:43
-
-
Save miketierney/365305 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var appVer = navigator.appVersion; | |
var searchVersion = /\s(\d)_\d/; | |
var searchDevice = /\s[(](\w+\s?\w*)[;]\s/; | |
var isIPhone = false; | |
var isIPad = false; | |
if (searchVersion.exec(appVer) && searchDevice.exec(appVer)){ | |
var deviceVersion = searchVersion.exec(appVer)[1]; | |
if ("iPhone" == searchDevice.exec(appVer)[1]){ isIPhone = deviceVersion; } | |
if ("iPhone Simulator" == searchDevice.exec(appVer)[1]){ isIPhone = deviceVersion; } | |
if ("iPad" == searchDevice.exec(appVer)[1]){ isIPad = deviceVersion; } | |
} | |
if(isIPad){ alert("iPad Version: " + isIPad ); } | |
if(isIPhone){ alert("iPhone Version: " + isIPhone); } | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment