jQuery browser detection - oh yeah! Posted by Mischa S.


Date: October 17, 2012

So, if you're not able to use the fantastic tags, such as these:

<!--[if lt IE 9]>
do stuff

Then, we're stuck digging through the DOM and Googling for a while to remember all the conditional statements from hell that we used to be stuck with.  But, like a heartburn pill at a chili-cook-off, JQUERY TO THE RESCUE!

if($.browser.msie){ //we are IE...blech
		if($.browser.version.slice(0,3) < 9){//it's worse than we though

More info here on jQuery browser detection here: http://api.jquery.com/jQuery.browser/

Also, this is deprecated as of version 1.3, but in this particular instance (I'm stuck working in a CMS system that doesn't allow the above tags) it's the way to go.  Future versions of jQuery could yank this object, so if you use it, caution given!