Thread View: borland.public.cppbuilder.internet.web
2 messages
2 total messages
Started by Eduardo Jauch
Thu, 01 Feb 2007 18:15
Find and click a link with CppWebBrowser
Author: Eduardo Jauch
Date: Thu, 01 Feb 2007 18:15
Date: Thu, 01 Feb 2007 18:15
59 lines
2408 bytes
2408 bytes
I loaded a page in my program using TCppWebBrowser, that cointais these
lines (among many others):
<a href="javascript: confirmarInformacoesDeVisto();">
<img src="bt_voltar.gif" border="0"></a>
<a href="javascript: confirmarAgendamento();">
<img src="bt_confirmar.gif" border="0"></a>
<a href="javascript: listaSituacaoAgendamento();">
<img src="bt_cancelar.gif" border="0"></a>
How can I execute by program the second line?
I mean, how can I "simulate" by my program the click of the mouse in the
specified link by a user?
I saw a code on another post that execute a "click" on a button (by Remy).
#include <mshtml.h>
#include <utilcls.h>
if( CppWebBrowser1->Document )
{
TComInterface<IHTMLDocument2> Doc;
CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&Doc);
if( Doc )
{
TComInterface<IHTMLElementCollection> All;
Doc->get_all(&All);
if( All )
{
TComInterface<IDispatch> Disp;
All->item(TVariant(WideString("secure_exit")),
TVariant(0), &Disp);
if( Disp )
{
TComInterface<IHTMLElement> Element;
Disp->QueryInterface(IID_IHTMLElement,
(LPVOID*)&Element);
if( Element )
Element->click();
}
}
}
}
But in this example, the "button" has a name,
<input TYPE="button" NAME="secure_exit" VALUE=" Finished "
onClick="logout();">
And my "links" don't have...
So, how to FIND the right link in the page and how to execute it?
Re: Find and click a link with CppWebBrowser
Author: Eduardo Jauch
Date: Fri, 02 Feb 2007 20:08
Date: Fri, 02 Feb 2007 20:08
13 lines
1316 bytes
1316 bytes
I saw in another post (that I can't remember where), that Javascript can
be put in Navigate like a URL...
So I don't need to find my links, I need only to execute a new Navigate
to that link...
Like:
Browser->Navigate(WideString("javascript: myfunc()"));
But anyway, how to find the links in the page?
Thanks :)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads