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 利用51.la统计程序使用量

Delphi 获取某个页面所有的链接

Delphi 通用压缩单元

Delphi d10.x 在android 9及更高版本下使用Delphi获取设备序列号?

Delphi 获取本机 hostname ip address

解放程序员!Delphi带来app开发革命

Delphi fastreport快速安装教程

Delphi获取机器的mac地址

Delphi combobox 只读 text属性可用的方法

Delphi xmldocument控件之xml

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



打赏

取消

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

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

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

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

评论

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