Soak blog

ronansprake

21.12.2009

By: ronansprake

Under: Technical

Detecting IE6 without jQuery.browser

I would never normally recommend browser sniffing, but as long as the spectre of IE6 still haunts us, we need a way to patch the many holes of this spectacularly bad browser.

jQuery.browser has been superseded by jQuery.support, allowing detection for feature support rather than user agent (which is a very blunt tool). The jQuery team has made it a main objective to remain backwards-compatible, but I always prefer to phase out deprecated methods sooner rather than later.

What’s the answer?

Instead of this:

if (parseInt(jQuery.browser.version) == 6) { ... }

Try this:

if (typeof document.body.style.maxHeight == "undefined"){ ... }

Any script inside the second statement will execute only in browsers that don’t support the maximum-height property, which includes all versions of Internet Explorer up to version 6.

Tags: , ,

Leave a Reply