Last active
December 14, 2015 20:19
-
-
Save ingowennemaring/5142976 to your computer and use it in GitHub Desktop.
Detect features and devices via JavaScript
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
// Engine/OS | |
var is_iPhone = navigator.platform.indexOf('iPhone') >= 0; | |
var is_iPad = navigator.platform.indexOf('iPad') >= 0; | |
var is_iOS = this.is_iPhone || this.is_iPad; | |
var is_iOS5 = this.is_iOS && window.navigator.appVersion.indexOf('OS 5_') >= 0; | |
var is_webkit = 'webkitRequestAnimationFrame' in window; | |
var is_win = navigator.appVersion.indexOf("Win") >= 0; | |
var is_mac = navigator.appVersion.indexOf("Mac") >= 0; | |
// Features | |
var is_touchDevice = ('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0); | |
var is_html5video = typeof HTMLVideoElement !== 'undefined'; | |
var is_html5audio = typeof HTMLAudioElement !== 'undefined'; | |
var is_html5canvas = typeof HTMLCanvasElement !== 'undefined'; | |
var is_retina = window.devicePixelRatio > 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment