gpt4 book ai didi

delphi - 如何避免嵌入 iframe 元素的 OnDocumentComplete 事件?

转载 作者:行者123 更新时间:2023-12-03 14:56:53 26 4
gpt4 key购买 nike

我想防止 iframe 元素每次都触发 OnDocumentComplete 事件。例如,一个页面有 4 个 iframe,当我加载此页面时,我的 OnDocumentComplete 事件运行 4 次。我想为每个页面运行一次 OnDocumentComplete 。我怎样才能做到这一点?

也许我可以删除或阻止 TWebBrowser 控件中的 iframe

最佳答案

事件OnDocumentComplete主文档中的每个 FRAME/IFRAME 都会被触发。
如果您想忽略它们,请尝试以下操作:

procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
// check that the event is raised for the top-level browser (not frames or iframes)
if pDisp = TWebBrowser(Sender).ControlInterface then
begin
// do something nice...
end;
end;
<小时/>

来自德尔福文档:

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.

Sender is the Web browser that is loading the document.

pDisp is the Automation interface of the top-level frame or browser. When loading a document without frames, pDisp is the interface of the Web browser. When loading a document with multiple frames, this is the interface of the containing frame, except for the very last time the event occurs, when it is the interface of the Web browser.

关于delphi - 如何避免嵌入 iframe 元素的 OnDocumentComplete 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10105150/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com