为什么WebBrowser下载完成一个页触发两次onDocumentComplete事件

xieg 2005-12-03 05:50:17
为什么WebBrowser下载完成一个页触发两次onDocumentComplete、onNavigateComplete、onNavigateComplete事件。
如果在这些事件下作处理数据容易出错,请教一下大家不如何解决。
...全文
889 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
QQgenie 2005-12-19
  • 打赏
  • 举报
回复
onDocumentComplete事件的完成不一定是真正的完成.

如果打开一个不存在的页面,或打开不了该页面,当一定时间后,onDocumentComplete事件照样发生,无论是用上面的
IF CurWebrowser = TopWebBrowser then

或用
if WebBrowser1.ReadyState = READYSTATE_COMPLETE then

都不能判断网页被真正下载.

所以得自己加一个判断有没有"无法找到该页"或"无法找到网页"来判断.

真搞不懂WebBrowser控件这么不好用!
leonkim 2005-12-05
  • 打赏
  • 举报
回复
Occurs when the document being navigated to reaches ReadyState_Complete.

Delphi syntax:

property OnDocumentComplete: TWebBrowserDocumentComplete;

Description

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.
zhuminghua 2005-12-05
  • 打赏
  • 举报
回复
mark
aiirii 2005-12-04
  • 打赏
  • 举报
回复
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
CurWebrowser: IWebBrowser;
TopWebBrowser: IWebBrowser;
Document: OleVariant;
WindowName: string;
begin
CurWebrowser := pDisp as IWebBrowser;
TopWebBrowser := (Sender as TWebBrowser).DefaultInterface;
if CurWebrowser = TopWebBrowser then
ShowMessage('Complete document was loaded')
else
begin
Document := CurWebrowser.Document;
WindowName := Document.ParentWindow.Name;
ShowMessage(Format('Frame "%s" was loaded', [WindowName]));
end;
end;


这个可以知道真正的 onDocumentComplete
蒋晟 2005-12-04
  • 打赏
  • 举报
回复
每个单独的框架都可能会触发DocumentComplete事件。
框架集页面会最后触发DocumentComplete事件。
发送事件的对象可以通过DocumentComplete事件的第一个参数访问
ccrun.com 2005-12-03
  • 打赏
  • 举报
回复
因为你浏览的页面可能有框架,框架中包含多少个页面,就会触发多少个onDocumentComplete事件。

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧