Created
April 29, 2011 04:37
-
-
Save christopherhein/947843 to your computer and use it in GitHub Desktop.
Extending Moderizer so that is adds browsers and operating systems
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
(function($){ | |
$(function() { | |
var userAgent = navigator.userAgent.toLowerCase(); | |
jQuery.browser = { | |
chrome: /chrome/.test( userAgent ), | |
safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ), | |
opera: /opera/.test( userAgent ), | |
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), | |
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) | |
}; | |
$.each($.browser, function(i, val) { if(val) { $("html").addClass(i) } }); | |
var osname = "unknownos"; | |
if ( navigator.appVersion.indexOf("Win") !=-1 ) osname = "windows"; | |
if ( navigator.appVersion.indexOf("Mac") !=-1 ) osname = "mac"; | |
if ( navigator.appVersion.indexOf("X11") !=-1 ) osname = "unix"; | |
if ( navigator.appVersion.indexOf("Linux") !=-1 ) osname = "linux"; | |
$("html").addClass(osname); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment