$. Browser. version often has some inaccurate situations. Recently, I have made some summary and do not know whether to fully use it $. browser. version often has 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 7.0. "The version obtained after force resolution is still 7.0. If you want webbrowser to obtain 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:
The Code is as follows:
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;
}
}
2. Use" "Force resolution. My machine is IE9. After this label is added, the version obtained by $. browser. version 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.