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

  • Thread starter Thread starter Peter
  • Start date Start date
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,
 
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??
 
Back
Top