开发者

jquery.browser giving false positives

开发者 https://www.devze.com 2023-01-19 18:00 出处:网络
I want to exclude some code from browsers开发者_C百科 earlier than ie8, but I am failing at the first hurdle.

I want to exclude some code from browsers开发者_C百科 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;

            } 
        });


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


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

Take this in consideration ;) link text


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号