With $. browser. version, there are often some inaccurate situations. Recently, I have made some summary and do not know whether it is comprehensive or not.
The obtained result is the same with navigator. userAgent. indexOf ("MSIE 8.0") of javasript.
1. Use webbrowser to load htm and html pages. At this time, it is inaccurate to obtain the IE version after loading. For example, my machine is IE9, but after loading through webbrowser, $. browser. the version obtained by the version method is changed to 7.0, and "<meta http-equiv =" x-ua-compatible "content =" IE = 5; IE = 7; IE = 8; IE = 9; "/>" the version obtained after force resolution is still 7.0. If you want webbrowser to get the correct result, you still need to modify the registry.
The solution to this problem is to obtain it through the registry in the background:
Copy codeThe Code is as follows:
<Span style = "font-size: 18px;"> private int GetIEVersion ()
{
Using (Microsoft. Win32.RegistryKey versionKey = Microsoft. Win32.Registry. LocalMachine. OpenSubKey (@ "Software \ Microsoft \ Internet Explorer "))
{
String version = versionKey. GetValue ("Version"). ToString ();
Int iVersion = int. Parse (version. Substring (0, 1 ));
Return iVersion;
}
} </Span>
2. Use "<meta http-equiv =" x-ua-compatible "content =" IE = 5; IE = 7; IE = 8; "/>" to force resolution, my machine is IE9. After adding this label, then $. browser. the version obtained is 8.0.
3. nested Iframe. If the outer layer is IE8 resolution and the inner layer is IE9 resolution, the version obtained in the inner layer is IE9, but the page is actually parsed according to IE8, this will cause the judgment to be inconsistent with the actual execution.
In this case, the number of applications should be relatively small. If the application needs to be resolved through internal and external layer resolution, the problem can be solved.