在网络浏览器控件中查找文本
我有一个网络浏览器控件,已经导航到一个页面。现在我想在页面中搜索特定文本,并滚动到第一个出现的位置。
能够滚动到其他事件是一个好处。
I have a web browser control, already navigated to a page. Now I want to search for a specific text in the page, and scroll to the first occurrence.
Being able to scroll to other occurrences is a bonus.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以尝试以下代码:
webBrowser1.Select();
SendKeys.Send("^f");
You can try this code:
webBrowser1.Select();
SendKeys.Send("^f");
我不知道它是否适用于
WebBroswer
。我们使用以下代码使浏览器(IE/FF/etc)窗口滚动到某些文本:如果我希望窗口滚动到“关键字”,只需访问
http://www.sample.com/sample .html#aim
使用
string document = myWebBrowser.DocumentText
获取页面的源代码,并搜索字符串中的文本,获取其节点名称,并使用进行导航>#。
I don't know if it works in a
WebBroswer
. We make the broswer(IE/FF/etc) window scroll to some text with the following code:If I want the window to scroll to the "KeyWord", simply visit
http://www.sample.com/sample.html#aim
Using
string document = myWebBrowser.DocumentText
to get the source code of the page, and search the text in the string, get its node name, and navigate it using#
.看看这个是否有帮助:
See this if it helps:
一种方法...
使用
Ctrl
+F
键调用 WebBrowser 控件本机的Find
?One way...
Use the
Ctrl
+F
Key to invokeFind
, native to the WebBrowser Control?