就是OnDocumentComplete事件,看该事件的说明:
Write an OnDocumentComplete event handler to take specific action when a frame or document is fully loaded into the Web browser .For a document without frames, this event occurs once when the document finishes loading. On a document containing multiple frames, this event occurs once for each frame. When the multiple-frame document finishes loading, the Web browser fires the event one final time.
对于没有frame结构的页面,页面读取完毕会触发这个事件
对于有多个frame结构的页面,每个frame读取完毕都会触发这个事件,当所有frame都读取完毕后会触发最后整个页面读取完毕的事件,你可以使用该事件的URL来判断是否所有frame都读取完毕
用下面的程序来做测试,打开的是猫扑大杂烩的页面,典型的frame结构网页:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, ExtCtrls;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
TestURL:string='http://dzh.mop.com/mainFrame.jsp';
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate(TestURL);
end;
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
if url=TestURL then showmessage('网页打开完毕');
end;
end.