Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When IE8 is not IE8 what is $.browser.version?

IE8 can go into IE7 mode if it needs to. How does jQuery detect this? Specifically, what is the value of $.browser.version?

like image 573
nickf Avatar asked Dec 03 '22 14:12

nickf


2 Answers

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

like image 90
DmitryK Avatar answered Dec 06 '22 03:12

DmitryK


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

like image 37
James Wiseman Avatar answered Dec 06 '22 05:12

James Wiseman