#3169 closed bug (duplicate)
Browser Detection is incorrect
Reported by: | chrisbarr | Owned by: | flesler |
---|---|---|---|
Priority: | major | Milestone: | 1.3 |
Component: | core | Version: | 1.2.6 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
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 (1)
Change History (13)
comment:1 Changed 15 years ago by
Component: | site → core |
---|---|
need: | Review → Test Case |
Priority: | major → minor |
comment:2 Changed 15 years ago by
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.
comment:3 Changed 15 years ago by
Owner: | set to flesler |
---|---|
Priority: | minor → major |
Status: | new → assigned |
comment:4 Changed 15 years ago by
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) ?
comment:5 Changed 15 years ago by
need: | Test Case → Patch |
---|
Ok yes, We could add a specific check for IE7, lemme pull out a patch.
Changed 15 years ago by
Attachment: | ie7-version[5791].diff added |
---|
What do you think about this patch ?
comment:7 Changed 15 years ago by
How about?
jQuery.browser.msie && parseInt(jQuery.browser.version) == 6 && this.XMLHttpRequest
comment:8 Changed 14 years ago by
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;
comment:9 Changed 14 years ago by
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;
comment:10 Changed 14 years ago by
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)
comment:13 Changed 14 years ago by
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
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.