Skip to content

Instantly share code, notes, and snippets.

@oti
Last active August 29, 2015 14:24
Show Gist options
  • Save oti/a0f5af120d367ee6fc11 to your computer and use it in GitHub Desktop.
Save oti/a0f5af120d367ee6fc11 to your computer and use it in GitHub Desktop.
ua_detecter
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());
@oti
Copy link
Author

oti commented Jul 8, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment