Zach’s ugly mug (his face)

Zach Leatherman

jQuery Bug: IE reports incorrect $.browser.version

October 19, 2008

Warning

This article is old and may contain information that is outdated, irrelevant, or—dare I say it—no longer accurate. Read with care!

Update: This is now fixed in jQuery.

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;

Zach’s ugly mug (his face)

Zach is a builder for the web with IndieWeb Avatar for https://www.netlify.comNetlify. He created the IndieWeb Avatar for https://www.11ty.devEleventy site generator and is still fixated on web fonts. His public speaking résumé includes talks in eight different countries at events like Jamstack Conf, Beyond Tellerrand, Smashing Conference, CSSConf, and The White House. He is an emeritus of Filament Group, NEJS CONF, and still helps out with nebraskajs’s AvatarNebraskaJS. Read more about Zach »

Previous
DOMContentLoaded Inconsistencies (in Browsers and JavaScript Libraries)
Next
Dear IE6: Please Cache my Images.
3 Comments
  1. ege madra Disqus

    15 Sep 2009
    Very useful, thanks for sharing.
  2. manu Disqus

    15 Apr 2010
    Cool,thank you
  3. Пол Disqus

    14 Nov 2013
    Напиши пожалуйста как установить социальные кнопки.Пол.Please write how to install a social button..: VSIIDB@i.ua Thank you

Shamelessly plug your related post:

Sharing on social media?

This is what will show up when you share this post on Social Media:

How did you do this? I automated my Open Graph images. (Peer behind the curtain at the test page)