delphi webbrowser 获取iframe

procedure TForm1.Button4Click(Sender: TObject);
var
Index: Integer;
Document: IHTMLDocument2;
FrameIdx: OleVariant;
FrameDis: IDispatch;
FrameWin: IHTMLWindow2;
input:IHTMLElement;
cardno,name,money,selbank,paypwd,strbank:string;
P : TPoint;
begin
while Webbrowser1.ReadyState <> READYSTATE_COMPLETE do
Application.ProcessMessages;

if WebBrowser1.Document = nil then Exit;
if WebBrowser1.Document.QueryInterface(IHTMLDocument2, Document) <> 0 then Exit;

FrameIdx := 0;
FrameDis := Document.frames.item(FrameIdx);
if FrameDis.QueryInterface(IHTMLWindow2, FrameWin) <> 0 then Exit;
framedis:=framewin.document.frames.item(FrameIdx);
if FrameDis.QueryInterface(IHTMLWindow2, FrameWin) <> 0 then Exit;
//memo1.Lines.Add( framewin.document.body.outerHTML);
//FrameWin.document 就是你要的每个 Frame 的文档

end;

你可能感兴趣的:(WebBrowser)