Created
April 13, 2010 21:17
-
-
Save jordandobson/365095 to your computer and use it in GitHub Desktop.
This file contains 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
This should detect if you have an iPad or iPhone and store the version number in either the isIPhone or isIPad variable.
You can see an example of this script here: http://jordandobson.com/_expirements/iphone-ipad/version_detect.html
NOTE: If you don't use an iPhone or iPad to load the page you won't get an alert.