jQuery.browser.version Doesn’t Recognise IE7 Anymore

March 14th, 2008

Recently i’ve noticed that jQuery.browser.version seems to be returning 6 for most copies of IE7. This seems to be due to the fact that the user-agent string now contains the substring “MSIE 6.0″. So, thanks for that Microsoft.

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0
(compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.1.4322; .NET
CLR 2.0.50727; .NET CLR 3.0.04506.30)

See what they’ve done there? Genius.

I wouldn’t reccomend using jQuery.browser.version for anything important but if you need to you can weed out IE6 by extending $.browser like this:

The Workaround

$.browser.msie6 =
$.browser.msie
&& /MSIE 6\.0/i.test(window.navigator.userAgent)
&& !/MSIE 7\.0/i.test(window.navigator.userAgent);

The most critical effect of this i’ve seen is with Thickbox. Thickbox identifies the browser as IE6 and incorrectly attempts to position the Thickbox window using an IE6 hack, resulting in the image being displayed off-centre. I’ve detailed how to patch the current 3.1 release on the support forum

Update: More information about this bug and how it affects Thickbox, along with some patched copies of thickbox.js can now be found here

July 2008: A fringe case where Internet Explorer will return a MSIE 6.0 user agent string when the user agent string exceeds 260 characters has been identified. Read more here

Posted in Web | Tagged with:

3 Responses

  1. Zoom

    Hi, I’ve tried replacing the code after you answered here:
    http://wordpress.org/support/topic/173000?replies=7#post-754059 , but I’m still having some errors. Do you think you can take a look?

    Thanks.

  2. Jamie Thompson

    I’ve managed to get the ticket for this bug upgraded from minor to major
    http://dev.jquery.com/ticket/3169

  3. Eric Martin » jQuery & Browser Issues

    […] In certain situations, jQuery’s $.browser.version will report IE 7 as version 6. Jamie Thompson noted one possible situation on his blog, but typically the issue is caused due to the fact that some copies of IE 7 included MSIE 6.0 within its user-agent string. […]

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.