Solved

How can I extract all of links from TWebBrowser

Posted on 2004-08-05
2
671 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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now