procedure websubmit(WB: TWebBrowser; FieldName: string); var I: Integer; FormNr, ItemNr : integer; TheForm : Variant; o : Olevariant;
begin //判断是否存在form对象 if WB.OleObject.Document.All.Tags('FORM').Length = 0 then begin ShowMessage('Error: no FORM found on page'); Exit; end;
for FormNr := 0 to WB.OleObject.Document.Forms.Length - 1 do begin //取得每一个form对象 TheForm := WB.OleObject.Document.Forms.Item(FormNr);
for ItemNr := 0 to TheForm.Length - 1 do begin try //根据form对象中的的元素名确定是否是需要提交的那个按钮 //form对象包括input,select button等 //比如<input type=submit name='aaaa"> //则name为 aaaa if TheForm.Item(ItemNr).Name = FieldName then begin TheForm.Item(ItemNr).CLICK; //模拟点击 exit; end; except Break; end; end; end; end;