views:

58

answers:

2

hey guys

Post Sniffing Rules

Although browser sniffing used to be quite popular, it's now gone out of fashion (for good reasons) and has been deprecated (if not dropped) by popular libraries such as jquery.

The better way is to do feature detection.

Exception To The New Rule

However, there are times when you might be targeting (for whatever reason) a specific browser. iOS safari is a good example, as are other mobile browsers, as the mobile platform has different ui concerns.

My Particular Purpose

For my purposes, I want to target IE specifically in order to alert the user to use another browser.

You may not agree with what I want to do, but please disregard that in your answer.

With this in mind, what the best, most reliable way to detect browser versions, more specifically any IE version, and iOS Safari too.

Is it safe to still use jquery.browser?

+2  A: 

Use Conditional Comments. The are a perfect fit for what you're after.

Andrew
+1 cool, so that's for ie only right?
andy
Correct. Feature detection is a reasonable solution -- but it suffers from one major drawback: over time you should expect browsers to change their implementation and (hopefully) become more standards-compliant (or at least more compliant with other browsers' standards). That means you have to stay on top of browser changes and periodically tweak your tests to make sure they still accurately differentiate between browsers. That's why, I think, jQuery stopped recommending `browser` and instead pushed `supports`.
Andrew
A: 

Also, it's all very well and good to tell people to use feature detection but in the real world, when you have 3 days to update the browser detection on your company's website you can't go and re-write all the Javascript just to take advantage of this, so I say, heck yes, use browser sniffing, because sometimes you don't have a choice.

RaresMan