JQuery to get the IE version of webbrowser inaccurate solution

  • 2020-03-30 02:06:52
  • OfStack

With $. Browser. Version often appear some inaccurate situation, recently encountered, made some summary, do not know whether comprehensive.

Use javasript navigator. UserAgent. IndexOf (" MSIE 8.0 ") determining the result is the same.

1. Load HTM and HTML pages with webbrowser, and it is not accurate to get the version of IE after loading. For example, my machine is IE9. Meta HTTP - equiv = "x - ua - compatible" content = "IE = 5; IE = 7; IE = 8; IE = 9." / >" The version obtained after forced parsing is still 7.0, and if you want webbrowser to get the correct results, you still need to modify the registry.

The solution to this problem is to get:
 
<span style="font-size:18px;">private int GetIEVersion() 
{ 
using (Microsoft.Win32.RegistryKey versionKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SoftwareMicrosoftInternet 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." / >" Force resolution, my machine is IE9, after adding this label, and then $. Browser. Version is 8.0.

3, nested Iframe status, if the outer layer is IE8 resolution, the inner layer is IE9 resolution, so the version of the inner layer is IE9, but in fact, the page is in accordance with IE8 to resolve, this will cause judgment and actual execution is not consistent.

This situation should be relatively rare, if the need to pass the inner and outer layer analysis at the same time judgment can be solved.

Related articles: