通过德尔福在网页上pressing按钮 [英] Pressing Buttons on a web page via Delphi
问题描述
练习1:<一href=\"http://stackoverflow.com/questions/10593494/programmaticaly-click-on-a-link-in-webbrowser-using-dom-delphi-7\">WebBrowser.OleObject.Document.GetElementByID('ID这里')点击;
练习2:<一href=\"http://stackoverflow.com/questions/3651054/how-to-find-a-button-with-value-in-html-page-webbrowser-delphi\"><输入类型=提交VALUE =登录>
上面的两个例子是通过对德尔福网页pressing按钮。 EX2行之有效的各种网站,但不是全部。这是因为练习2只适用于HTML按钮?我试着练习1但一些code丢失,当我尝试它,我得到一个消息,说'需要对象或类类型。同时练习1没有例如code,任何人都可以填补我为什么我得到这个消息,并把一些code为练习1,请。
The above two examples are for pressing buttons on web pages via Delphi. Ex2 works well on various web sites but not all. Is this because Ex2 only works on HTML buttons? I tried Ex1 but some code is missing, when I try it, I get a message saying 'Object or class type required'. Also Ex1 has no example code, can anyone fill me in on why I get this message and put some code up for Ex1 please.
推荐答案
我从这个code:MrBaseball34在的 delphipages
因为我写的,而不是WebBrowser1'web浏览器它没有开始工作。但它完美。
这里是code:
I got this code from: MrBaseball34 at delphipages It didn't work initially because I wrote 'WebBrowser' instead of 'WebBrowser1'. But it works perfectly. Here is the code:
procedure TForm1.Button1Click(Sender: TObject);
var
x: integer;
thelink: OleVariant;
begin
thelink:= WebBrowser1.OleObject.Document.all.tags('A');
if thelink.Length > 0 then
begin
for x := 0 to thelink.Length-1 do
begin
if Pos('put id string here', thelink.Item(x).id) > 0 then
begin
thelink.Item(x).click;
Break;
end;
end;
end;
end;
这篇关于通过德尔福在网页上pressing按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!