WebBrowser控件使用IE9 [英] WebBrowser control to use IE9

查看:716
本文介绍了WebBrowser控件使用IE9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想WebBrowser控件使用IE9。 IE9安装在计算机上,但WebBrowser控件仍在使用IE8。

I want that the WebBrowser control to use IE9. IE9 is installed on the computer, but the WebBrowser control is still using IE8.

我验证与 http://www.whatbrowser.org/en/ 。我尝试做一些更改注册表(找到了解决办法在这里),但不工作。

I verified with http://www.whatbrowser.org/en/. I try to make some changes to the registry (found a solution here) but is not working.

推荐答案

我认为这是正在传递到网站的用户代理字符串。它被正确地识别它作为IE8的,因为它可能无法满足他们的逻辑的要求相匹配的IE9。我可以看到同样的事情发生在我的盒子也是如此。你可以指定用户代理字符串,如果你想使用。添加到您的项目

I think it is the user agent string that is being passed to the site. It is misidentifying it as IE8 as it might not be meeting the requirements in their logic to match as IE9. I can see the same thing happen on my box as well. You could specify the user agent string to use if you want. Add this to your project

在您的使用语句添加...

In your using statements add ...

using System.Runtime.InteropServices;

在你的表单类添加....

Within your form class add ....

[DllImport("urlmon.dll", CharSet = CharSet.Ansi)]
private static extern int UrlMkSetSessionOption(int dwOption, string pBuffer, int dwBufferLength, int dwReserved);
const int URLMON_OPTION_USERAGENT = 0x10000001;

public void ChangeUserAgent(String Agent)
{
    UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, Agent, Agent.Length, 0);
}

然后,只需调用它的地方,在你的code ...也许构造,或Form_Load事件。

Then just call it somewhere in your code ... maybe the constructor, or the form_load event.

ChangeUserAgent("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");

这篇关于WebBrowser控件使用IE9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆