Return to Snippet

Revision: 80638
at March 23, 2020 17:12 by chrisaiv

Updated URL

Updated Code

Updated Description

Revision: 9039
at October 18, 2008 12:05 by chrisaiv

Initial Code
//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("padding", "1em 1.8em" );

Initial URL

Initial Description
There have been a few times where I've been forced to reduce myself to browser sniffing.  In this example, I'm making an ad hoc change to CSS but for anyone interested in making changes to IE6/IE7 only, there's a better way.  Take a look at my other snippet.

Initial Title
JQuery: Common Browser Sniffing

Initial Tags
browser, jquery

Initial Language