同时填充 html 输入字段和 tedit
我想创建一个带有 twebbrowser 和 tedit 框的表单,如果需要的话还可以更多。
然后可以说,我希望浏览器位于 google.com 上,当我在搜索栏中输入内容时,我希望它也输入 tedit。最好是同时进行,但如果我点击离开也没关系,它也会填充 tedit 框。我只是想了解这是如何工作的,在网站上键入并自动键入编辑框。
有人可以帮助我吗?
I want to create a form with a twebbrowser and a tedit box, more if needed.
Then lets say, I want the browser to be on google.com and when I type in the search bar I want it to type in the tedit as well. Best would be at the same time but it is fine if i click away it will fill in the tedit box as well. i just want to understand how this work, Type on the site and have the edit boxed automatically typed as well.
anyone can help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
TWebBrowser
中没有任何事件(据我所知)在您编辑位置时触发(我不认为TWebBrowser
有搜索栏,所以我认为这就是你的意思是)。当我尝试使主机应用程序与
TWebBrowser
保持同步时,我使用了OnBeforeNavigate2
事件。There is no event in
TWebBrowser
(so far as I know) that fires as you edit the location (I don't thinkTWebBrowser
has a search bar so I presume that's what you mean).When I have tried to keep a host app in sync with a
TWebBrowser
I have used theOnBeforeNavigate2
event.我还没有尝试过这个,但我不久前为该网站添加了书签。
从 JavaScript 调用 Delphi
文章讨论了如何调用来自 TWebBrowser 的 delphi 代码。您可以通过声明接口来实现外部对象扩展,然后将其注册到浏览器控件。这样,您应该能够在网站中使用 JavaScript 调用 delphi 方法。
您必须控制 TWebBrowser 中显示的源,因此 google 示例将不起作用。 ...当然,除非您在 TWebBrowser 中显示之前通过注入自定义代码来操纵 html 源。
我希望这能让你走上正轨......
I haven't tried this, but I bookmarked the web site a while ago.
Calling into Delphi from JavaScript
The article discusses how to call delphi-code from the TWebBrowser. You implements an external object extension by declaring an interface, and then registers it with the browser control. Doing that, you should be able to invoke delphi methods by using JavaScript in the web site.
You have to be in control of the source that is shown in the TWebBrowser, so the google example wouldn't work. ...unless you manipulate the html-source by injecting custom code before you show it in the TWebBrowser, of cource.
I hope this may put you the right track...
阅读您的评论,您可以考虑反过来做:
在 TEdit 中键入搜索(并处理您需要的所有日志记录),然后导航 TWebBrowser 到此 url:
'http://www.google.com/search?q= ' + Edit1.Text
Reading your comment, you may consider to do it the other way around:
Type the search in the TEdit (and handle all the logging you need), and then navigate the TWebBrowser to this url:
'http://www.google.com/search?q=' + Edit1.Text