IE8 can go into IE7 mode if it needs to. How does jQuery detect this? Specifically, what is the value of $.browser.version
?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
IE8 in IE7 mode will report IE7. BUT you can analyse user-agent and check for "Trident/4.0". If you see this line then you work with IE8
JQuery can only see what the browser tells it.
In IE7 mode the browser will report itself as IE7, so that is what JQuery will see.
The
$.browser
obejct is populated using a concept know as Browser-Sniffing. Put simply, this is the processes scanning data out of the user-agent string which is sent by browsers, robots, and anything else that accesses the page.Due to the susceptiblity of the user agent to faking, this object is deprecated in later versions of jQuery. Object Detection and Feature Detection (see
$.support
) are now used in preference.For example, Opera 8.5. used to identify itself as IE: http://www.javascriptkit.com/javatutors/navigator.shtml
$.support:
http://docs.jquery.com/Utilities/jQuery.support
User Agents:
http://en.wikipedia.org/wiki/User_agent
http://www.zytrax.com/tech/web/browser_ids.htm
Object detection:
http://www.quirksmode.org/js/support.html http://developer.apple.com/internet/webcontent/objectdetection.html
Browser Sniffing:
http://en.wikipedia.org/wiki/Browser_sniffing
Feature Detection:
http://docs.jquery.com/Utilities/jQuery.support
I'm a .NET developer and I always like to use a Sessions.aspx page that I created for this kind'a problems
Fell free to use it, I can share the code as well.
as you can see by this screencast that I just made (14 sec) you get MSIE 8 and MSIE 7 specified in the javascript navigator property, they change when you change compatibility mode as the engine that renders the page is slight different (remember that is not 100% IE7 engine!)
instead of using the jQuery buit in method, just use the normal javascript
IE8 in IE7 mode
IE8 in native mode
code:
I just tested this out myself (having just downloaded IE8)
When you put IE8 into IE7 compatibility mode with the meta tag like this:
The value of
$.browser.version
is still 8.0!