Solved

WebBrowser, following a url.

Posted on 2003-10-21
1
153 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
[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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month4 days, 3 hours left to enroll

630 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