Bug Tracker

Ticket #3169 (assigned bug)

Opened 6 months ago

Last modified 3 months ago

Browser Detection is incorrect

Reported by: chrisbarr Assigned to: flesler (accepted)
Type: bug Priority: major
Milestone: 1.3 Component: core
Version: 1.2.6 Keywords:
Cc: Needs: Patch

Description

I was trying to make some IE7 specific code and I soon realized that IE7 is incorrectly reported as version 6.0 in JQuery. Open up IE7 and head to http://docs.jquery.com/Utilities/jQuery.browser and then head to another JS based test like http://www.quirksmode.org/js/detect.html and you will see that it's being reported differently.

On the same note, I'm also running Firefox 3 and It's being reported as version 1.9.0.1 by JQuery.

Attachments

ie7-version[5791].diff (411 bytes) - added by flesler 6 months ago.
What do you think about this patch ?

Change History

Changed 6 months ago by flesler

  • priority changed from major to minor
  • need changed from Review to Test Case
  • component changed from site to core
  • owner deleted

Can you add the userAgent of both browsers ? Get into this link and copy paste it into here (the version too please).

Btw, check the link that says "modified version" and see if the version reported is fixed in this one.

Changed 6 months ago by jamiethompso

This shouldn't have a minor priority. browser.version returns 6.0 in many installations of IE7. This is because the user agent string contains both "compatible; MSIE 7.0;" and "compatible; MSIE 6.0;" and the result varies depending on which is presented first in the string.

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)

The current regexp "userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ )" is no longer adequate for differentiating between IE6 and IE7.

A simple test like typeof document.body.style.maxHeight !== "undefined" would help to differentiate between a browser that really is IE6 or just IE7 presenting itself oddly.

Obviously as I say, this is pretty easy to workaround if you know about it. But this is a massive trip up for those who don't and it wreaks havoc with plugins that try and use browser.version to apply hooks into CSS workarounds for IE6.

Changed 6 months ago by flesler

  • priority changed from minor to major
  • status changed from new to assigned
  • owner set to flesler

Changed 6 months ago by jamiethompso

Update: It seems that in some cases, because of a bug IE7 actually returns a user agent string of:

Mozilla/4.0 (compatible; MSIE 6.0)

The reasons for this are explained on my blog but revolve arounf browser toolbars and spyware messing with registry entries relating to the user agent string

Microsoft bashing aside, it looks as though accurately determining the Internet Explorer version has to involve more than just doing a regexp on the user agent string. IE7 is just far too unreliable in this respect.

I guess the question is should jQuery.browser.version simply represent what the user agent string reports or should it try it's best to report the actual browser version (using object detection and such) ?

Changed 6 months ago by flesler

  • need changed from Test Case to Patch

Ok yes, We could add a specific check for IE7, lemme pull out a patch.

Changed 6 months ago by flesler

What do you think about this patch ?

Changed 6 months ago by flesler

Ok, that's wrong, it won't catch IE8...

Changed 6 months ago by jamiethompso

How about?

jQuery.browser.msie && parseInt(jQuery.browser.version) == 6 && this.XMLHttpRequest

Changed 5 months ago by emartin24

What about something like:

// Fix copies of IE7 that report MSIE 6.0 jQuery.browser.version = jQuery.browser.msie && parseInt(jQuery.browser.version) == 6 && windowXMLHttpRequest? ?

"7.0" : jQuery.browser.version;

Changed 5 months ago by emartin24

Sorry:

// Fix copies of IE7 that report MSIE 6.0
jQuery.browser.version = jQuery.browser.msie && parseInt(jQuery.browser.version) == 6 && window["XMLHttpRequest"] ?
	"7.0" :
	jQuery.browser.version;

Changed 5 months ago by pschelotto

And how about changing:

userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ )

by

userAgent.match( /.*?(?:rv|it|ra|ie)[\/: ]([\d.]+)/ )

(tested in ie6, ie7 and Firefox)

Changed 3 months ago by Web Developm

I have the same problem with IE 8. shall i use same tactic to resolve problem.

Note: See TracTickets for help on using tickets.