Created
February 12, 2012 12:26
-
-
Save tikitikipoo/1808259 to your computer and use it in GitHub Desktop.
Javascriptでデバイスがiosかどうか判別
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
// 出所:http://stackoverflow.com/questions/9038625/detect-if-device-is-ios | |
var iOSversion = false, | |
w = window, | |
p = navigator.platform; | |
if( p === 'iPad' || p === 'iPhone' || p === 'iPod' ){ | |
!!w.history && !!w.history.pushState ? iOSversion = '4+' : iOSversion = '4-'; | |
!!w.matchMedia ? iOSversion = '5+' : ''; | |
} | |
// Another way to do it is using navigator.appVersion: | |
var iOSversion = false, | |
p = navigator.platform; | |
if( p === 'iPad' || p === 'iPhone' || p === 'iPod' ){ | |
iOSversion = navigator.appVersion.split(' ')[0] || false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment