Skip to content

Instantly share code, notes, and snippets.

@michaeldoye
Created February 28, 2017 06:48
Show Gist options
  • Save michaeldoye/f622e8796f686b7c6bab287f86c7e5e4 to your computer and use it in GitHub Desktop.
Save michaeldoye/f622e8796f686b7c6bab287f86c7e5e4 to your computer and use it in GitHub Desktop.
jQuery(document).ready(function($) {
// http://stackoverflow.com/a/9851769/3055401
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
// Internet Explorer 6-11
var isIE = /*@cc_on!@*/false || !!document.documentMode;
// Edge 20+
var isEdge = !isIE && !!window.StyleMedia;
// Chrome 1+
var isChrome = !!window.chrome && !!window.chrome.webstore;
// Blink engine detection
var isBlink = (isChrome || isOpera) && !!window.CSS;
if (isEdge) {
$('body').addClass('edge-browser');
}
else if (isFirefox) {
$('body').addClass('firefox-browser');
}
else if (isChrome) {
$('body').addClass('chrome-browser');
}
else {
// Do nothing
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment