WebBrowser组件不显示CSS 3 [英] WebBrowser component not showing CSS 3

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

问题描述

我正在建立一个需要WebBrowser组件的软件。
不幸的是,它不会正确显示我的页面。



我的内容使用这种CSS样式:

  .content_mid {
background-image:url(http://img.awesome-o.net/Content_Mid.png);
background-size:100%100%;
vertical-align:text-top;
padding-left:40px;
padding-right:20px;
min-height:400px;由于我已经发现WebBrowser组件使用的是已安装的版本的interwebs explorer,因此我们可以看到,



在这里你可以看到它在IE上显示的内容:





这里是如何在webbrowser组件上显示:





因此,我检查了浏览器版本:

  Debug.WriteLine(WebBrowser version:+ webBrowser1.Version); 
输出:WebBrowser版本:9.0.8112.16443

这样应该是可以的。 / p>

解决方案

只是为了进一步参考其他需要此功能的人:



的所有:
感谢 Boo & Lex Li
帮助我找到我的问题的答案。



您必须将某个注册表设置为正确的值:


32个键有两组位和64位应用程序。


32位:



< HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

价值键:yourapplication.exe

64位:

  HKEY_LOCAL_MACHINE\SOFTWARE \Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION 

价值键:yourapplication.exe

将此键设置为的值(取自MSDN此处为十进制值):

  9999(0x270F)
Internet Explorer 9.网页以IE9标准模式显示,而不管!DOCTYPE指令。

9000(0x2328)
Internet Explorer 9.包含基于标准的网页!DOCTYPE伪指令以IE9模式显示。

8888(0x22B8)
无论!DOCTYPE指令如何,网页都以IE8标准模式显示。

8000(0x1F40)
包含基于标准的!DOCTYPE指令的网页以IE8模式显示。

7000(0x1B58)
包含基于标准的!DOCTYPE指令的网页以IE7标准模式显示。

即使强大的MSDn声称9000是自动分配的值。这不是真的。



下面你可以找到代码如何添加这些键到您的注册表。

  RegistryKey key = Registry.LocalMachine.OpenSubKey(@SOFTWARE\\ \\ Microware \Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION,true); 
if(key!= null)
{
key.SetValue(YourApplicationName.exe,9000,RegistryValueKind.DWord);
}

key = Registry.LocalMachine.OpenSubKey(@SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION,true);
if(key!= null)
{
key.SetValue(YourApplicationName.exe,9000,RegistryValueKind.DWord);
}

感谢所有和好运



编辑:应关闭用户帐户控制以使此代码生效。


I am building a piece of software that requires a WebBrowser component. Unfortunately it won't show my page correctly.

My content uses this CSS style:

.content_mid{
background-image:url(http://img.awesome-o.net/Content_Mid.png);
background-size: 100% 100%;
vertical-align:text-top;
padding-left: 40px;
padding-right:20px;
min-height:400px; 
}

Since I already found out the WebBrowser component uses the installed version of interwebs explorer, I checked the html on Internet Explorer, and it shows perfectly.

Here you see what it shows on IE:

And here is how it displays on the webbrowser component:

So, I checked the browser version:

Debug.WriteLine("WebBrowser version: " + webBrowser1.Version);
output: WebBrowser version: 9.0.8112.16443

So that should be alright I guess.

解决方案

Just for further reference to other people needing this:

First of all: Thanks to Boo & Lex Li For helping me find the answer to my question.

You have to set a certain registry to the right value:

There are two different sets of keys for 32 bit and 64 bit applications.

32 bit:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

Value Key: yourapplication.exe

64 bit:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION

Value Key: yourapplication.exe

The value to set this key to is (taken from MSDN here) as decimal values:

9999 (0x270F)
Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the  !DOCTYPE directive.

 9000 (0x2328)
 Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.

8888 (0x22B8)
Webpages are displayed in IE8 Standards mode, regardless of the !DOCTYPE directive.

8000 (0x1F40)
Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.

7000 (0x1B58)
Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.

Even tough MSDn claims that 9000 is the automatically assigned value. Apperently this is simply not true.

Below you can find the code how to add these keys to your registry. Please not that your application has a different processname when you debug.

RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
        if (key != null)
        {
            key.SetValue("YourApplicationName.exe", 9000, RegistryValueKind.DWord);
        }

        key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
        if (key != null)
        {
            key.SetValue("YourApplicationName.exe", 9000, RegistryValueKind.DWord);
        }

So thanks all and Good Luck

Edit: User Account Control should be off to make this code work.

这篇关于WebBrowser组件不显示CSS 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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