窗体上放一个Button1和WebBrowser1
const TimeOunt=30;//超时时间
...
var
BrowseTime:integer; //正在访问的页面花费的浏览时间
Complete:boolean; //完成标志
...
procedure TForm1.Button1Click(Sender: TObject);
begin
BrowseTime:=0;
Complete:=false;
WebBrowser1.Navigate(Page.Url,Flags);
while (not Complete and(BrowseTime<TimeOut) do//浏览器有可能浏览超时
begin
BrowseTime:=BrowseTime+1;
sleep(3000);
end;
ShowMessage('浏览完毕!');
end;
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
Complete:=true;
end;