1、老外写的:
procedure TForm1.Button2Click(Sender: TObject);
var
i:Integer;
begin
Listbox1.Clear;
//if frames available
if Webbrowser1.OleObject.Document.Frames.Length <> 0 then
begin
//walk through all frames and get the url
//to the Listbox
for i:=0 to Webbrowser1.OleObject.Document.Frames.Length -1 do
begin
Listbox1.Items.Add(Webbrowser1.OleObject.Document.Frames.item(i).Document.URL);
end;
end;
end;
2、我用IHTMLFRAMECOLLECTION2写的。
procedure TForm1.Button5Click(Sender: TObject);
var
i:integer;
j
levariant;
doc:ihtmldocument2;
frameele:ihtmlframescollection2;
oneframe:Ihtmlwindow2;
spdisp:idispatch;
begin
doc:=webbrowser1.document as ihtmldocument2;
frameele:=doc.frames;
for i:= 0 to frameele.length-1 do begin
j:=i;
spDisp:=Frameele.item(j);
if SUCCEEDED(spDisp.QueryInterface(IHTMLWindow2 ,oneframe))then
memo1.Lines.Add(oneframe.document.title);
end;
end;