Using the WinForms WebBrowser
control in edit mode (as described here), I am experiencing unnecessary scrollbars when switching the control into "IE9 mode".
I'm using the meta tag
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
as described in this posting to switch into editing mode.
This is how it looks like when being in "IE9 mode":
In contrast, when using it without the above meta tag, it correctly looks like this:
Here, it looks as expected; the horizontal scrollbar is not present at all and the vertical scrollbar is not active.
I tried every DOCTYPE I can think of; the result seems to stay the same.
(In case it matters: The content that is being switched into edit mode comes from a local HTTP URL of the built-in mini webserver of my application, i.e. not from a string or from a file URL).
My question is:
Is there a way to use the WebBrowser
control with IE9 in "IE9 edit mode" and still have the scrollbars only when necessary?
Using your browser's magnification or zoom controls may cause scroll bars to disappear. Observe this phenomenon by opening a Web page and pressing "Ctrl-<minus symbol>" repeatedly. Your actions cause the page's content to shrink in size.
The scrollbars in the Web Browser control is determined by the document scroll settings and you can use the overFlow style to turn it off.
The following code works for me in preventing any scrollbars to appear:
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";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With