以前一个大虾写的,改了一下
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, OleCtrls, SHDocVw, MSHTML;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure WebBrowser1DownloadComplete(Sender: TObject);
private
{ Private declarations }
FDownComplete : Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
ovDoc, ovForm, ovInput, ovTag: OleVariant;
I : Integer;
begin
if not FDownComplete then Application.MessageBox('网页正在下载中,请稍后……', '提示', MB_OK + MB_ICONINFORMATION)
else begin
ovDoc := WebBrowser1.Document;
ovForm := ovDoc.forms;
ovInput := ovform.Item(0);
for I := 0 to ovInput.length -1 do begin
ovTag := ovInput.item(I);
if (ovTag.Type = 'button') and (ovTag.value = 'NEW') then begin
ovTag.Click;
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FDownComplete := False;
WebBrowser1.Navigate('file:///c:/a.htm');
end;
procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
begin
FDownComplete := True;
end;
end.