How To Target Firefox  2

I was recently working on a project that had some issues in Firefox 2.0, but not Firefox 3.0. Generally I would frown on this sort of “browser sniffing” approach, but for this it was a requirement and there seemed to be no way around it.

I’ve used jQuery’s $.browser() method to add a class of ff2 to the <body> tag if the browser is indeed Firefox 2.0.

$(function(){
	if ($.browser.mozilla && $.browser.version.indexOf('1.8.') > -1) {
		$('body').addClass('ff2');
	}
});

Hopefully this helps someone else out there!

Meet the Author

Kevin Leary, WordPress Consultant

I'm a custom WordPress web developer and analytics consultant in Boston, MA with 17 years of experience building websites and applications. View a portfolio of my work or request an estimate for your next project.