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

查看:91
本文介绍了如何在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);


推荐答案

要滚动到特定位置,可以使用< a href = https://msdn.microsoft.com/zh-cn/library/1e8xf2s3(v=vs.110).aspx rel = nofollow> 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天全站免登陆