Skip to content

Instantly share code, notes, and snippets.

@0xnbk
Created September 13, 2010 04:15
Show Gist options
  • Save 0xnbk/576795 to your computer and use it in GitHub Desktop.
Save 0xnbk/576795 to your computer and use it in GitHub Desktop.
Detect browser
//A. Target Safari
if( $.browser.safari ) $("#menu li a").css("padding", "1em 1.2em" );
//B. Target anything above IE6
if ($.browser.msie && $.browser.version > 6 ) $("#menu li a").css("padding", "1em 1.8em" );
//C. Target IE6 and below
if ($.browser.msie && $.browser.version <= 6 ) $("#menu li a").css("padding", "1em 1.8em" );
//D. Target Firefox 2 and above
if ($.browser.mozilla && $.browser.version >= "1.8" ) $("#menu li a").css("
@0xnbk
Copy link
Author

0xnbk commented Sep 13, 2010

Detect browser

Although it is better to use CSS conditionnal comments to detect a specific browser and apply some css style, it is a very easy thing to do with JQuery, which can be useful at times.

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