views:

20

answers:

3

I want to exclude some code from browsers earlier than ie8, but I am failing at the first hurdle.

at present, my code should only detect if it is IE at all, but it doesn't

$.each(jQuery.browser, function(i, val) {
            if (i!='msie'){
                notIE = true;

            } 
        });
A: 

Documentation about this said that I'll be preferable to use navigator.userAgent.

Take this in consideration ;) link text

Arnaud F.
A: 

Check out http://www.quirksmode.org/css/condcom.html. You can use a conditional comment to set an IE variable if it is IE. This is really the only way I've found to guarantee that a browser is IE and what version.

Also, people these days are tending to go away from detecting the browser to detecting features.

Jason Thompson
+2  A: 

I would say better use IE conditional comments instead of sniffing the agent (does not smell good)..

In regard to the actual question, better use the jQuery.browser.msie and jQuery.browser.version directly

Gaby