Last active
August 29, 2015 14:24
-
-
Save oti/a0f5af120d367ee6fc11 to your computer and use it in GitHub Desktop.
ua_detecter
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
var _ua = (function(u){ | |
return { | |
ltIE6:typeof window.addEventListener == "undefined" && typeof document.documentElement.style.maxHeight == "undefined", | |
ltIE7:typeof window.addEventListener == "undefined" && typeof document.querySelectorAll == "undefined", | |
ltIE8:typeof window.addEventListener == "undefined" && typeof document.getElementsByClassName == "undefined", | |
ltIE9:document.uniqueID && typeof window.matchMedia == "undefined", | |
gtIE10:document.uniqueID && window.matchMedia, | |
gtIE11:document.uniqueID && document.documentMode >= 11, | |
Trident:document.uniqueID, | |
Gecko:'MozAppearance' in document.documentElement.style, | |
Presto:window.opera, | |
Blink:window.chrome, | |
Webkit:typeof window.chrome == "undefined" && 'WebkitAppearance' in document.documentElement.style, | |
Touch:typeof document.ontouchstart != "undefined", | |
Mobile:(typeof window.orientation != "undefined") || (navigator.userAgent.indexOf("Windows Phone") != -1), | |
ltAd4_4:typeof window.orientation != "undefined" && typeof(EventSource) == "undefined", | |
Pointer:window.navigator.pointerEnabled, | |
MSPoniter:window.navigator.msPointerEnabled, | |
Tablet:(u.indexOf("windows") != -1 && u.indexOf("touch") != -1) | |
|| u.indexOf("ipad") != -1 | |
|| (u.indexOf("android") != -1 && u.indexOf("mobile") == -1) | |
|| (u.indexOf("firefox") != -1 && u.indexOf("tablet") != -1) | |
|| u.indexOf("kindle") != -1 | |
|| u.indexOf("silk") != -1 | |
|| u.indexOf("playbook") != -1, | |
Mobile:(u.indexOf("windows") != -1 && u.indexOf("phone") != -1) | |
|| u.indexOf("iphone") != -1 | |
|| u.indexOf("ipod") != -1 | |
|| (u.indexOf("android") != -1 && u.indexOf("mobile") != -1) | |
|| (u.indexOf("firefox") != -1 && u.indexOf("mobile") != -1) | |
|| u.indexOf("blackberry") != -1 | |
})(window.navigator.userAgent.toLowerCase()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From W3G.
https://w3g.jp/blog/js_browser_sniffing
https://w3g.jp/blog/js_browser_sniffing2015