delphi webbrowser 跨域访问


本文整理自网络,侵删。

 
procedure IterateFrames(const AWB: IWebBrowser2);
var
Doc: IHTMLDocument2;
Container: IOleContainer;
Enumerator: ActiveX.IEnumUnknown;
Unknown: IUnknown;
Browser: IWebBrowser2;
Fetched: Longint;
NewDoc: IHTMLDocument2;
begin
if (Assigned(AWB.Document)) and (Supports(AWB.Document, IHTMLDocument2, Doc)) then
begin
// Recursive searching.
// ACHTUNG! We cannot use the document's frames collection here, because
// it does not work in every case (i.e. Documents from a foreign domain).
// From: support.microsoft.com/support/kb/articles/Q196/3/40.ASP
if (Supports(Doc, IOleContainer, Container)) and (Container.EnumObjects(OLECONTF_EMBEDDINGS, Enumerator) = S_OK) then
begin
while Enumerator.Next(1, Unknown, @Fetched) = S_OK do
if (Supports(Unknown, IWebBrowser2, Browser)) and (Supports(Browser.Document, IHTMLDocument2, NewDoc)) then
begin
//DoSomethingWithNewDoc;
IterateFrames(AWB);
end;
end;
end;
end;

来源:https://www.cnblogs.com/honeynm/p/4653651.html

相关阅读 >>

Delphi 遍历某字段并插入到combobox

怀念一下这些经常不记得的Delphi代码

Delphi中几种程序自我删除的方法

Delphi touchkeyboard1 基本用法

Delphi驱动开发研究第一篇--实现原理

Delphi在postgresql中读写二进制数据

Delphi 关于datetimepicker的一点问题(同时修改日期和时间的实现)

Delphi inc函数和dec函数的用法

Delphi listview 排序功能

Delphi synedit1 synmemo1 显示行号

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...