Last active
December 15, 2015 22:59
-
-
Save naotone/5336806 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
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