简体   繁体   中英

How to vertical scroll down in web browser control

How can I scroll down the scroll bar in WebBrowser component in c#?
I tried the following code , but it doesn't did the job:

webBrowser2.Focus();
webBrowser2.Document.Body.ScrollIntoView(false);

To scroll to a specific location, you can use WebBrowser.Document.Window.ScrollTo(x,y) method. For example to scroll down to the end of body:

private void webBrowser1_DocumentCompleted(object sender, 
                                           WebBrowserDocumentCompletedEventArgs e)
{
    webBrowser1.Document.Window.ScrollTo(0, webBrowser1.Document.Window.Size.Height);
}

To scroll to a specific element, you can use ScrollIntoView method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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