jQuery Bug: IE reports incorrect $.browser.version

I’ve witnessed installations of IE where the navigator.userAgent reported both MSIE 6.0 and MSIE 7.0 in the same string, when Internet Explorer 7 is the one that’s really installed. Turns out, this is problematic for jQuery version 1.2.6, as it parses the double version userAgent as Internet Explorer 6, which may cause problems with your code if you’re using $.browser.version.

You can monitor the jQuery bug in the bug tracker, or see the original research performed by Jamie Thompson. Here’s a better workaround that merges two different approaches used on Jamie’s page, which fixes $.browser.version instead of using $.browser.msie6. This is to be considered temporary until the next (fixed) version of jQuery comes out.

jQuery.browser.version = jQuery.browser.msie && /msie 7\.0/i.test(navigator.userAgent) ?
	"7.0" :
	jQuery.browser.version;
VN:F [1.9.3_1094]
Rating: 4.6/5 (7 votes cast)
jQuery Bug: IE reports incorrect $.browser.version, 4.6 out of 5 based on 7 ratings
This entry was posted in Other. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. ege madra
    Posted September 15, 2009 at 9:07 am | Permalink

    Very useful, thanks for sharing.

  2. manu
    Posted April 15, 2010 at 12:43 pm | Permalink

    Cool,thank you

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Additional comments powered by BackType