Reputation: 10677
The lowest browser my application supports is IE 7. I have some code that works fine in IE 8, but needs to be avoided in IE 7. There are a ton of questions/answers on here that indicate how to detect IE 7 with .browser
but none that indicate how to detect only IE 7 with .support
. The jQuery page detailing .support does not make it clear which supported features are present in which browsers, so not getting much help there.
Upvotes: 1
Views: 1061
Reputation: 207557
Did you look at the API for $.browser?
http://api.jquery.com/jQuery.browser/#jQuery-browser-version2
But there is a reason why it is deprecated, it is a bad thing to do. You should sniff using feature detection.
Upvotes: 0
Reputation: 2762
The reason they deprecated .browser is to try to encourage us to test for features instead of browsers.
However.. if you still need to...
Have you considered using H5BP's conditional <html>
trick and then just testing for that? Header:
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
Then in jQuery,
$(function() {
if( !$('html').hasClass('lt-ie8') ) {
// Do stuff
}
});
Upvotes: 3
Reputation: 708186
It is nearly always better to identify the features you are targeting in IE8 and use "feature detection" to see if they are available (by testing the feture's functionality) and if they are not available, then use alternate code (for IE7 or any other browser without that feature).
If you offer more specifics on the functionality that doesn't work in IE7, we could help you solve this problem with feature detection, not browser version detection.
Upvotes: 0