C#WebBrowser:绘制圆圈?

时间:2016-01-27 10:18:42

标签: c# css css3 webbrowser-control css-shapes

我正在编写一个简单的可视化应用程序,我有一个小问题: webBrowser.Version返回Build: 9600 Major: 11,尽管我无法使用现代CSS3功能绘制圆圈。下面是我得到的HTML代码和输出。我尝试了在谷歌上找到的各种方法,似乎没有任何工作。删除了不必要的代码,只留下了在webBrowser中不起作用的部分。

哦,顺便说一句,它在独立IE中打开时有效。也试过`border-radius:50%

here is image of what I get

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Main Window</title>
    <style>
        .circle {
            border-radius: 10px;
            width: 20px;
            height: 20px;
            background: blue;
        }
    </style>
</head>
<body>
    <div class="circle"></div>
</body>
</html>

2 个答案:

答案 0 :(得分:3)

这是因为WebBrowser类模拟IE,因此将HKEY设置为模拟中使用的IE版本。

以下是一些建议或替代方案。

元标记

<meta http-equiv="X-UA-Compatible" content="IE=10" />

将上述内容添加到您的HTML中,它会尝试强制浏览器在IE10中显示内容。

机器上的HKEY更改

找到以下HKEY的

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

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

并将您的应用更改或添加到像这样的值

FEATURE_BROWSER_EMULATION "myAppName.exe"=10000

HKEY更改代码

要执行与上述相同的操作,但在代码中,请使用以下内容:

RegistryKey registrybrowser = Registry.LocalMachine.OpenSubKey
           (@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true);
        registrybrowser.SetValue("myAppName.exe", 10000, RegistryValueKind.DWord); 

答案 1 :(得分:0)

我认为WebBrowser卡在IE7或IE8上。几年前我尝试了一些这些黑客来改变它的版本:

https://weblog.west-wind.com/posts/2011/May/21/Web-Browser-Control-Specifying-the-IE-Version

另外Use latest version of Internet Explorer in the webbrowser control

相关问题