如何在 Web 浏览器控件中垂直向下滚动 [英] How to vertical scroll down in web browser control

查看:26
本文介绍了如何在 Web 浏览器控件中垂直向下滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 c# 中的 WebBrowser 组件中向下滚动滚动条?
我尝试了以下代码,但没有成功:

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);

推荐答案

要滚动到特定位置,您可以使用 WebBrowser.Document.Window.ScrollTo(x,y) 方法.例如向下滚动到正文的末尾:

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);
}

要滚动到特定元素,您可以使用 ScrollIntoView 方法.

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

这篇关于如何在 Web 浏览器控件中垂直向下滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆