Return to Snippet

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


Updated URL
https://www.chrisjmendez.com/2008/10/18/jquery-common-browser-sniffing/

Updated Code
https://www.chrisjmendez.com/2008/10/18/jquery-common-browser-sniffing/

Updated Description
https://www.chrisjmendez.com/2008/10/18/jquery-common-browser-sniffing/

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.
http://snipplr.com/view/9095/html-conditional-html-for-ie6-and-ie7/

Initial Title
JQuery: Common Browser Sniffing

Initial Tags
browser, jquery

Initial Language
JavaScript