Solved

WebBrowser, following a url.

Posted on 2003-10-21
1
145 Views
Last Modified: 2010-04-05
Hey,

Is it possible to let your application simulate a click on a link on a site in a WebBrowser component. The first part of the url it has to click on is unique but the other part does change everytime you surf though.

Thanks in advance!
0
Comment
Question by:JuicyJ
1 Comment
 
LVL 3

Accepted Solution

by:
Peter_ earned 125 total points
ID: 9594320
Import typelibrary MSHTML.pas from MSHTML.dll

With this typelibrary you can then seach your document to find the right MSHTML Element.

First get hold of the IDocument3 interface, by typecasting Webbrowser1.Document:

var
  MyDocument: IDocument3;

MyDocument := (Webbrowser1.Document as IDocument3);

If you know the name of the element that has the link, you might use:

var
 MyElement: IHTMLElement;

MyElement := (MyDocument.getElementsByName('NameOfMyElement').item(0, '') as IHTMLElement);

MyElement.Click might then do the trick? If not, then try typecast to some subclass. Make sure to have the typecast within try/except as it might fail. I have not tried to navigate links, just posted forms.
Perhaps if only you can get hold of the right URL, then Webbrowser1.Navigate('...') would work as well.

If you don't know the name of the element, you might loop the MyDocument.all collection looking for a possible match:

var
 MyCollection: IHTMLElementCollection;

MyCollection := (MyDocument.all as IHTMLElementCollection);

for i:=0 to MyCollection.Count-1 do
 MyElement := (MyCollection[I] as IHTMLElement);
 ...

You may also try using MyDocument.getElementsByTagName(const v: WideString) to get a collection of all elements of a specific type.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

18 Experts available now in Live!

Get 1:1 Help Now