例如在此代码中:
procedure TForm1.WebBrowser1DownloadComplete(Sender: TObject);
begin
ShowMessage('Download Completed');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WebBrowser1.Navigate('http://www.google.com/');
end;
“WebBrowser1DownloadComplete”消息在 1 Navigate 上出现多次。
这很烦人,并且使该事件几乎毫无用处。
为什么会发生这种情况?如何避免这种情况?
谢谢
最佳答案
也许 OnNavigationComplete2 事件处理程序更适合您的应用程序。
Occurs immediately after the Web browser successfully navigates to a new location.
Write an OnNavigateComplete2 event handler to take specific action when the Web browser successfully navigates to a new resource. The event can occur before the document is fully downloaded, but when it occurs at least part of the document must be received and a viewer for the document created.
关于Delphi:WebBrowser 的 OnDownloadComplete 一次发生多次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11594160/