procedure TForm1.WebBrowser1NewWindow2(Sender: TObject;
var ppDisp: IDispatch; var Cancel: WordBool);
var
sURL: string;
begin
sURL := IWebBrowser(ppDisp).LocationURL;
...
end;
、提取网页中所有链接
var
doc:IHTMLDocument2;
all:IHTMLElementCollection;
len,i:integer;
item:OleVariant;
begin
doc:=WebBrowser1 .Document as IHTMLDocument2;
all:=doc.Get_links; //doc.Links亦可
len:=all.length;
for i:=0 to len-1 do begin
item:=all.item(i,varempty); //EmpryParam亦可
memo1.lines.add(item.href);
end;
end;