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 xe8中的firemonkey应用程序将文本复制到剪贴板

Delphi xe2支持zip压缩文件的操作了

Delphi xe 程序瘦身.编译后exe最低90kb

Delphi 10.3.1新的变量的声明方法

Delphi 子界判断的举例

Delphi几个进制相关的代码(hextoint、hextoasc)

Delphi win10系统已管理员的权限运行应用程序

Delphi 获取自身软件的版本号

Delphi gdi+ 文本输出

Delphi文件监视主单元文件

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



打赏

取消

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

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

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

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

评论

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