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;
|
请发表评论