Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WebBrowser, following a url.

Posted on 2003-10-21
1
Medium Priority
?
155 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 500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

670 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