jQuery & Browser Issues (revisited)

Back in August, I blogged about “three fairly significant browser issues” I had encountered while using jQuery. With the release of jQuery 1.3, and subsequent minor versions, I thought I’d take a look back at those browser issues and see if any of them had been resolved.

IE7

Recap: In certain situations, jQuery’s $.browser.version will report IE 7 as version 6.

Considering the problem is due to IE 7 having an incorrect user-agent, I’m not sure that this problem was up to jQuery to solve. It would have required the user-agent parsing code to check non-user-agent properties…which is probably a bad idea.

I found out that my original code suggestions might fail in situations where IE 6 is using a 3rd party library to add XMLHttpRequest support, so here are my updated IE 6 and IE 7 detection suggestions:

Override the $.browser.version value:

jQuery.browser.version = jQuery.browser.msie &&
    parseInt(jQuery.browser.version) >= 6 &&
    typeof window['XMLHttpRequest'] == "object" ?
        "7.0" :
        jQuery.browser.version;

Add a new msie6 property:

jQuery.browser.msie6 = jQuery.browser.msie &&
    parseInt(jQuery.browser.version) == 6 &&
    typeof window['XMLHttpRequest'] != "object";

Keep in mind that $.browser is now deprecated, which means it will go away at some point in a future release. I’m not going to get into the object detection vs browser sniffing debate, but just be aware!

Opera 9.5

Recap: Opera, in an effort to follow standards, changed where it was storing the value for the viewport height.

This issue was fixed in jQuery Ticket 3117 by Ariel Flesler. If you have Opera 9.5, you can test the results on this page.

Safari 3 (Windows)

Recap: The following element would not be hidden in Safari: $("<div/>").hide().appendTo('body');

I found out that this issue also occurs in Safari 4! The original jQuery ticket I mentioned was marked as a duplicate, but the issue was fixed in ticket 1239.

Summary

Besides the problems with the IE user-agent, the jQuery developers implemented fixes for the two other browser issues that I had previously blogged about. jQuery 1.3.x has a number of new features and code improvements and continues to be, IMO, the best available JavaScript library.

1 thought on “jQuery & Browser Issues (revisited)”

  1. Wonderful stuff – i love it when people write down their tiny problems, that’s really usefull.

    But your piece of code for jQuery.browser.version is kinda problematic: IE8 will show up as IE7, which may be ok for 80% of the usecases out there, but sometimes you have to divide 7 & 8. It’s ok, i just like to notice that for the other people.

Comments are closed.

Scroll to Top