Skip to content

Instantly share code, notes, and snippets.

@sproutventure
Created October 29, 2010 18:27
Show Gist options
  • Save sproutventure/654071 to your computer and use it in GitHub Desktop.
Save sproutventure/654071 to your computer and use it in GitHub Desktop.
IE browser body class
// Checks userAgent and adds body classes for IE
jQuery(document).ready(function() {
if (jQuery.browser.msie) {
jQuery('body').addClass('ie');
jQuery('body').addClass('ie' + $.browser.version.substring(0, 1));
}
});
@sproutventure
Copy link
Author

Minified:

$(document).ready(function(){var userAgent=navigator.userAgent.toLowerCase();if($.browser.msie){$('body').addClass('ie');$('body').addClass('ie'+$.browser.version.substring(0,1));}});

@sproutventure
Copy link
Author

            function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

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