Skip to content

Instantly share code, notes, and snippets.

@naotone
Last active December 15, 2015 22:59
Show Gist options
  • Save naotone/5336806 to your computer and use it in GitHub Desktop.
Save naotone/5336806 to your computer and use it in GitHub Desktop.
device = navigator.userAgent.toLowerCase()
Mac = device.match(/(mac)/)
Windows = device.match(/(windows)/)
iPhone = device.match(/(iphone|ipod)/)
iPad = device.match(/(ipad)/)
iOS = device.match(/(iphone|ipad|ipod)/)
android = device.match(/(android)/)
Chrome = device.match(/(chrome)/)
Safari = device.match(/(safari)/) and not device.match(/(chrome)/) and not device.match(/(iphone|ipad|ipod)/) and not device.match(/(android)/)
Firefox = device.match(/(firefox)/)
Opera = device.match(/(opera)/)
ie10 = device.match(/(msie\ 10\.0)/)
ie9 = device.match(/(msie\ 9\.0)/)
ie8 = device.match(/(msie\ 8\.0)/)
ie7 = device.match(/(msie\ 7\.0)/)
ie6= device.match(/(msie\ 6\.0)/)
#debug
alert device
if Safari
alert 'Safari'
if Chrome
alert 'Chrome'
if Opera
alert 'Opera'
if Firefox
alert 'Firefox'
if iPhone
alert 'iPhone'
if iPad
alert 'iPad'
if iOS
alert 'iOS'
if android
alert 'android'
if ie10
alert 'IE10'
if ie9
alert 'IE9'
if ie8
alert 'IE8'
if ie7
alert 'IE7'
if ie6
alert 'IE6'
if Mac
alert 'Mac'
if Windows
alert 'windows'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment