不显示CSS 3 WebBrowser组件 [英] WebBrowser component not showing CSS 3
问题描述
我建立一个软件,需要一个web浏览器组件。
不幸的是,将无法正确显示我的网页
I am building a piece of software that requires a WebBrowser component. Unfortunately it won't show my page correctly.
我的内容使用这个CSS样式:
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;
}
既然我已经找到了WebBrowser组件使用interwebs资源管理器的安装版本,我查了Internet Explorer中的HTML,它完美展现
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.
下面你看到它显示了IE浏览器:
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:
有两种不同的密钥组32 ,位和64位应用程序
There are two different sets of keys for 32 bit and 64 bit applications.
32位:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
Value Key: yourapplication.exe
64位:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
Value Key: yourapplication.exe
设置此键的值作为十进制值(从MSDN这里拍摄):
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.
即使艰难MSDN声称,9000是自动分配的值。 Apperently这是不正确的。
Even tough MSDn claims that 9000 is the automatically assigned value. Apperently this is simply not true.
下面你可以找到的代码如何将这些密钥添加到您的注册表。请不是你的应用程序在调试不同的processname。
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
编辑:用户帐户控制应关闭,使此代码的工作。
User Account Control should be off to make this code work.
这篇关于不显示CSS 3 WebBrowser组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!