Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var ua = navigator.userAgent.toLowerCase();
$.ua = {
isWindows: /windows/.test(ua), // Windows
isMac: /macintosh/.test(ua), // Mac
isIE: /msie (\d+)/.test(ua), // IE
isIE6: /msie (\d+)/.test(ua) && RegExp.$1 == 6, // IE6
isIE7: /msie (\d+)/.test(ua) && RegExp.$1 == 7, // IE7
isLtIE9: /msie (\d+)/.test(ua) && RegExp.$1 < 9, // IE9未満
isFirefox: /firefox/.test(ua), // Firefox
isWebKit: /applewebkit/.test(ua), // WebKit
isSafari: /safari/.test(ua) && !/chrome/.test(ua), // Safari
isChrome: /safari/.test(ua) && /chrome/.test(ua), // chrome
isTouchDevice: 'ontouchstart' in window, // touchDevice
isIOS: /i(phone|pod|pad)/.test(ua), // iOS
isIPhone: /i(phone|pod)/.test(ua), // iPhone, iPod touch
isIPad: /ipad/.test(ua), // iPad
isAndroid: /android/.test(ua), // Android
isAndroidMobile: /android(.+)?mobile/.test(ua) // Android mobile
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment