How to vertical scroll down in web browser control

后端 未结 1 1117
醉梦人生
醉梦人生 2020-12-18 08:09

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.Fo         


        
相关标签:
1条回答
  • 2020-12-18 08:52

    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.

    0 讨论(0)
提交回复
热议问题