Solved

How can I extract all of links from TWebBrowser

Posted on 2004-08-05
2
695 Views
Last Modified: 2008-01-09
How can I extract all of links fromTWebBrowser and put in ex. TMemo or RichEdit.
Like CopyShortcut in
Internet Explorer but for all links
on TWebBrowser

0
Comment
Question by:nikola_mk
2 Comments
 
LVL 4

Accepted Solution

by:
alikoank earned 150 total points
ID: 11729816
var
  doc: IHTMLDocument2;
  links: IHTMLElementCollection;
  currlink:IHTMLElement;
  i: integer;
begin
  doc := WebBrowser.Document as IHTMLDocument2;
  links := doc.Links;
  for i := 0 to links.length -1 do begin
         currlink := link.Item(i,'') as IHTMLElement;
         Memo1.lines.add(currlink.toString);
  end;
0
 
LVL 4

Expert Comment

by:ErikPhilips
ID: 11739843
You also need to add MSHTML_TLB to your uses clause.  If you do not have MSHTML_TLB you can create it by using the menu in delphi Project->Import Type Library->select 'Micrsoft HTML Object Library', unselect 'Generate Component Wrapper', click 'Create Unit'.

In the above code one line needs to be slightly modified:
       currlink := links.Item(i,'') as IHTMLElement;

If you wish to get more information out of the hyperlink you can:
var
  htmlLink: IHTMLAnchorElement;

htmlLink := links.item(i,'') as IHTMLAnchorElement;
then you have access to all the properties of the anchor element:
http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/anchorelement/anchorelement.asp
   
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question