I found a script error on the webpage today. After checking, I found that jquery is used. browser. when judging the browser version, the version returns ie8.0 to ie6.0. The same problem occurs in online search. However, most people report that the results are normal. Once again, I tested the problem, because my testing environment is win2008 (Windows NT 6.0), The results returned by win2003 or WINXP are normal (Windows NT 5.2). When I checked the jquery source code, I found that it was determined using regular expressions.Version: (useragent. Match (/. + (? : RV | it | Ra | IE) [\/:] ([\ D.] +)/) | [0, '0']) [1], He used Windows NT in navigator. useragent 6.0Resolved to the ie6.0 version. .
If the problem is found, you need to find a solution. The most direct solution is to modify the version parsing Regular Expression of jquery. Because it is difficult to modify jquery every time you upgrade jquery, jquery. browser and jquery. browser. version have been declared in another document of jquery's Latest Version 1.3.2.We recommend that you discard it., You can useJquery. SupportIn later versions, jquery. browser may be abandoned.
Use jquery. browser. the purpose of version is to detect IE6. Another solution is to use jquery. support. Check jquery. in the attribute description of support, boxmodel can detect IE6. The details of boxmodel are as follows:
Boxmodel: If the page and browser are rendered in W3C CSS box model, the value is true. Generally, this value is false in the geek mode of IE 6 and IE 7. This value is null before the document is ready.
However, I tested that IE6, IE7, and IE8 returned true. This is the description in this document. (test environment: win2003 + IE6, win2003 + IE7, win2008 + IE8, ). Now I have to test other attributes, but after testing all the other attributes in jquery. Support, I found that none of them can directly detect IE6. Google uses jquery. browser. version for detection. This is not acceptable in windows. Is there any other solution? Think about jquery just now. jquery. support. style returns false in IE6/IE7 and true only in IE8, so that I can indirectly detect IE6. The specific method is as follows:
$. Browser. MSIE & ($. browser. Version = "6.0 ")&&! $. Support. Style
Because jquery. browser. version can normally detect IE6 and IE7, and then combine them! $. Support. style is IE6.
In the end, this problem is solved, but it is not perfect. After all, jquery. browser may be discarded. However, since it is a bug, jquery will eventually solve it. I hope my friends in the garden can come up with better solutions.
Additional instructions
Jquery. browser. in version regular expressions, Windows 6.0 is incorrect. The real cause of the test is that the windows system version has different navigator versions. the values returned by useragent are also different. The following values are shown as follows:
Win2003 + IE7 navigator. useragent return value:
Mozilla/4.0 (Compatible; MSIE 7.0.; Windows NT 5.2;. Net CLR 1.1.4322;. Net CLR 2.0.50727;. Net CLR 3.0.04506.648;. Net CLR 3.5.21022;. Net CLR 3.0.20.6.2152;. Net CLR 3.5.30729)
Win2008 + IE8 navigator. useragent return value:
Mozilla/4.0 (Compatible; MSIE 8.0.; Windows NT 6.0; Trident/4.0; gtb6; Mozilla/4.0 (Compatible; MSIE 6.0.; Windows NT 5.1; sv1); Server Load balancer;. Net CLR 2.0.50727;. Net CLR 3.5.21022; CBA;. Net CLR 3.5.30729;. Net CLR 3.0.30618)
the corrected regular expression is like this. Version: (useragent. Match (/(?: RV | it | Ra | IE) [\/:] ([\ D.] +)/) | [0, '0']) [1] remove the . + . You can see the navigator in win2008 from the above value. MSIE 8.0 is the real browser version, and a compatible is added to the back of the returned values of useragent; MSIE 6.0 (I don't know what this is for. IE7 should also have this) , however, if . + (that is, match any character) The compatible above; MSIE 7.0 will be ignored.