whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

54 Visitors Online


 
...list all links of a page of a TWebbrowser?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (15):  
     


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;


{*****************}

{ if there are frames }

procedure TForm1.Button2Click(Sender: TObject);
var
  
u : variant;
  v : IDispatch;
  s : string;

  procedure RecurseLinks(htmlDoc: variant);
  var
    
BodyElement : variant;
    ElementCo: variant;
    HTMLFrames: variant;
    HTMLWnd : variant;
    j, i : integer;
  begin
    if 
VarIsEmpty(htmlDoc) then
      
exit;
    BodyElement := htmlDoc.body;
    if BodyElement.tagName = 'BODY' then
    begin
      
ElementCo := htmlDoc.links;
      j := ElementCo.Length - 1;
      for i := 0 to do
      begin
        
u := ElementCo.item(i);
        s := u.href;
        listLinks.Items.Add(s);
      end;
    end;
    HTMLFrames := htmlDoc.Frames;
    j := HTMLFrames.length - 1;
    for i := 0 to do
    begin
      
HTMLWnd := HTMLFrames.Item(i);
      RecurseLinks(HTMLWnd.Document);
    end;
  end// RecurseLinks
begin
  
v := WebBrowser1.document;
  listLinks.Clear;
  RecurseLinks(v);
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners