Solved

How can I extract all of links from TWebBrowser

Posted on 2004-08-05
2
719 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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