I have a .NET windows form page and a WebBrowser component inside. I load a page inside the web browser using the Navigate method as in:
webBrowser1.Navigate("http://www.stackoverflow.com");
The pages length is longer than the browsers height, so the vertical scroll bar appears. Now I want to move the scrollbar down to a specific position. More specifically I want to search for a specific peace of text inside the page, and scroll to that position.
This behavior is implemented in the built-in "Find" function of the browser, but I can't figure out how to call开发者_StackOverflow中文版 the Find function from within my code, without the Find window appearing. Although I don't want the Find window to appear, if the text matches are highlighted it is welcome.You could do it using anchors.
webBrowser1.Navigate("http://www.stackoverflow.com#myAnchor");
and in your html define this:
<a id="myAnchor" />
This is in itself not very flexible, but if you consistently add anchor tags to key structural parts of the html, you can always jump to the section, block, or div that you want.
精彩评论