简体   繁体   English

C#WebBrowser:画圆吗?

[英]C# WebBrowser: draw circle?

I'm writing one simple visualisation app and I have one little problem: webBrowser.Version returns Build: 9600 Major: 11 and despite that I can't use modern CSS3 features to draw circle. 我正在编写一个简单的可视化应用程序,但我webBrowser.Version一个小问题: webBrowser.Version返回Build: 9600 Major: 11 ,尽管如此,我无法使用现代CSS3功能绘制圆。 Below is HTML code and output I get. 以下是我得到的HTML代码和输出。 I tried various methods found on google and nothing seems to work. 我尝试了在Google上找到的各种方法,但似乎没有任何效果。 Deleted unnecessary code, left only part that is not working in webBrowser. 删除了不必要的代码,只保留了在webBrowser中不起作用的部分。

Oh, btw, it works when opened in standalone IE. 哦,顺便说一句,它在独立的IE中打开时有效。 Tried also `border-radius: 50% 也尝试过“边界半径”: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>

This is because the WebBrowser class emulates IE and therefore will have a HKEY setting the version of IE used in the emulation. 这是因为WebBrowser类模拟IE,因此将具有HKEY来设置模拟中使用的IE版本。

Below are a couple of suggestions or alternatives. 以下是一些建议或替代方案。

Meta Tag 元标记

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

Add the above to your HTML and it will try and force the browser to show the content in IE10. 将以上内容添加到HTML中,它将尝试强制浏览器在IE10中显示内容。


HKEY Change on machine HKEY在机器上更换

Find the below HKEY's 查找以下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

and change or add your App to the values like so 然后将您的应用更改或添加到类似的值

FEATURE_BROWSER_EMULATION "myAppName.exe"=10000

HKEY Change in Code HKEY代码更改

To do the same as above but within the code, use the following: 若要执行与上述相同的操作,但在代码内,请使用以下命令:

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

I think the WebBrowser is stuck at IE7 or IE8. 我认为WebBrowser卡在IE7或IE8上。 I tried some of these hacks a few years ago to change its version: 几年前,我尝试了其中一些黑客措施来更改其版本:

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

Also Use latest version of Internet Explorer in the webbrowser control 在浏览器控件中使用最新版本的Internet Explorer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM