如何在Web浏览器控件中垂直向下滚动

编程入门 行业动态 更新时间:2024-10-26 08:32:55
本文介绍了如何在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浏览器控件中垂直向下滚动

本文发布于:2023-10-08 08:58:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1472131.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   浏览器   如何在   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!