How to catch a click on webbrowser :(

A

Aleyna[]

Hi

I want to catch the clicks for a special hyperlink on a webbrowser component
in order to activate the print setup section of my program. I cannot use
javascript because I must handle the printable document, in fact, create it
dynamically using program. I got stuck here, how can I do that?
Can I use a special javascript command that sends browser any message and
warn it or something like that?
Any idea?


appreciate any help...
Thanks
 
L

Laura T.

The HTML page hosted in WebBrowser component can call back the application.
You need to add a little thing in the HTML file to handle the onclick event
of the special link:
Like this:
<a href="whatever" onclick="window.external.Test('called from script
code')">CLICK ME</a>

When clicked, the page will call your apps Test method passing the string as
a parameter.
This way you can make callbacks from the page to your app.
Just remember to set the ObjectForScripting property to this
(webBrowser1.ObjectForScripting=this;).
 
P

Paul Werkowitz

Am Wed, 28 Feb 2007 19:04:05 +0100 schrieb Laura T.:
The HTML page hosted in WebBrowser component can call back the application.
You need to add a little thing in the HTML file to handle the onclick event
of the special link:
Like this:
<a href="whatever" onclick="window.external.Test('called from script
code')">CLICK ME</a>

When clicked, the page will call your apps Test method passing the string as
a parameter.
This way you can make callbacks from the page to your app.
Just remember to set the ObjectForScripting property to this
(webBrowser1.ObjectForScripting=this;).
Interesting!

I have a similar need: I need to access the DOM element a user identifies
with the mouse. (Background: user is interested in certain parts of a
webpage and wants to have the data extracted). Is there a possibility to
find the element in the DOM the mouse is over or clicked etc, without
adding anything to the page?

Tnx!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top