Getting scroll value from WebBrowser Control C #

I am trying to get the scroll index Y for a webpage in a WebBrowser control, but I cannot access the values ​​of the built-in scrollbar.

Any ideas?

+3
source share
3 answers

For IE in standards mode (with a doctype type, as you say) scrollTopis an element property <html>, not <body>:

HtmlDocument htmlDoc = this.webBrowser1.Document;
int scrollTop = htmlDoc.GetElementsByTagName("HTML")[0].ScrollTop;

(A more convenient way to get to the item <html>would be nice if anyone knows about it.)

+4
source

HTML, ? , ...

htmlDoc.GetElementById( "tag_id_string_goes_here" ) ScrollIntoView ();.

true . ScrollRectangle .

+1
WebBrowser1.Document.Body.ScrollTop;
WebBrowser1.Document.Body.ScrollRectangle.Height;
+1
source

Source: https://habr.com/ru/post/1707035/


All Articles