您的位置:首页 > 其它

在TWebbrowser 中模拟点击一个提交按钮

2008-10-04 23:00 218 查看
http://www.delphibbs.com/keylife/iblog_show.asp?xid=1316

//------------------------------------------------------------------------------------------------------------------------
uses
MSHTML; //必须引用这个单元

var
iDoc: IHtmlDocument2;
i: integer;
ov: OleVariant;
iDisp: IDispatch;
iColl: IHTMLElementCollection;
InputImage: HTMLInputImage;
//-----------------form http://blog.csdn.net/laoli/----------------------
begin
WebBrowser1.ControlInterface.Document.QueryInterface(IHtmlDocument2, iDoc);
if not Assigned(iDoc) then
begin
Exit;
end;
ov := 'INPUT';
iDisp := iDoc.all.tags(ov);
if Assigned(IDisp) then
begin
IDisp.QueryInterface(IHTMLElementCollection, iColl);
if Assigned(iColl) then
begin
for i := 1 to iColl.Get_length do
begin
iDisp := iColl.item(pred(i), 0);
iDisp.QueryInterface(HTMLInputImage, InputImage);
if Assigned(InputImage) then
begin
if InputImage.Name = '提交 then
// ---------------------------------------如果按钮名是'提交',就填提交,否则填其他
begin
InputImage.Click; // ------------模拟点击
end;
end;
end;
end;
end;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐