JQuery's solution to obtaining inaccurate IE versions of webbrowser _ jquery

Source: Internet
Author: User
$. 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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.