WebBrowser control not respecting ‘return false;’ javascript call on links

P

Peter

Hi

I'd appreciate some help on this issue as I'm stumped.

My VB.NET app has an embedded WebBrowser control which hosts a web
appliction that I have not written and which I cannot change. This web
application sometimes returns False from a link which should prevent
the URL referred to in the HREF from being loaded.

The issue is demonstrated in the following simple code:

<html>
<head></head>
<body>
Clicking <a href="http://www.google.com.au/"
onclick="alert('Google should NOT load when you click OK'); return
false;">here</a> should only display an alert.<br>
If the page directs you to google it means the browser is not
honouring the 'return false;' for the onclick event.
</body>
</html>

If the above is saved to an HTML file and loaded in a standalone
browser clicking the link will display an alert and no further action
is taken. However, when the HTML file is loaded by the WebBrowser
control within my application the browser will display the alert, but
then follow through with the link and load the href (Google).

I can't be the only one to face this dilemma. Can someone tell me how
I make the WebBrowser control respect False returns from onClick
JavaScript events. Thanks.

Peter,
 
P

Peter

Hi

I'd appreciate some help on this issue as I'm stumped.

My VB.NET app has an embedded WebBrowser control which hosts a web
appliction that I have not written and which I cannot change. This web
application sometimes returns False from a link which should prevent
the URL referred to in the HREF from being loaded.

The issue is demonstrated in the following simple code:

<html>
    <head></head>
    <body>
       Clicking <a href="http://www.google.com.au/"
onclick="alert('Google should NOT load when you click OK'); return
false;">here</a> should only display an alert.<br>
If the page directs you to google it means the browser is not
honouring the 'return false;' for the onclick event.
    </body>
</html>

If the above is saved to an HTML file and loaded in a standalone
browser clicking the link will display an alert and no further action
is taken.  However, when the HTML file is loaded by the WebBrowser
control within my application the browser will display the alert, but
then follow through with the link and load the href (Google).

I can't be the only one to face this dilemma.  Can someone tell me how
I make the WebBrowser control respect False returns from onClick
JavaScript events.  Thanks.

Peter,

HELP! Is anyone able to help me here??
 

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