首页  编辑  

页面中的所有连接

Tags: /超级猛料/OS.操作系统/IE.扩展/TWebBrowser/页面内容/   Date Created:

list all links of a page of a TWebbrowser?

procedure TForm1.Button1Click(Sender: TObject);

var

 i: Integer;

begin

 for i := 0 to Webbrowser1.OleObject.Document.links.Length - 1 do

   Listbox1.Items.Add(Webbrowser1.OleObject.Document.Links.Item(i));

end;

对于多个Frame的页面,可以采取下面的代码:

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;