gpt4 book ai didi

c# - 在 IE9 模式下 WebBrowser 控件中不需要的滚动条

转载 作者:太空狗 更新时间:2023-10-29 21:35:39 26 4
gpt4 key购买 nike

使用 WinForms WebBrowser control在编辑模式 ( as described here ) 中,将控件切换到“IE9 mode ”时遇到不必要的滚动条。

我正在使用元标记

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

this posting 中所述切换到编辑模式。

这是在“IE9 模式”下的样子:

enter image description here

相比之下,在没有上述元标记的情况下使用它时,它看起来像这样:

enter image description here

在这里,它看起来符合预期;水平滚动条根本不存在,垂直滚动条不活动。

我尝试了所有我能想到的 DOCTYPE;结果似乎保持不变。

(以防万一:切换到编辑模式的内容来 self 的应用程序内置迷你网络服务器的本地 HTTP URL,即不是来自字符串或文件 URL)。

我的问题是:

有没有办法在“IE9 编辑模式”下将 WebBrowser 控件与 IE9 一起使用,并且仅在必要时仍然有滚动条?

最佳答案

Web Browser 控件中的滚动条由文档滚动设置决定,您可以使用 overFlow 样式将其关闭。

以下代码对我有用,可以防止出现任何滚动条:

    private void button1_Click(object sender, EventArgs e)
{
dynamic doc = this.Browser.Document.DomDocument;
dynamic body = this.Browser.Document.Body;
body.DomElement.contentEditable = true;

doc.documentElement.style.overflow = "hidden";
}

关于c# - 在 IE9 模式下 WebBrowser 控件中不需要的滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9294076/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com