Disha Shukla Disha Shukla - 1 year ago 112
Vb.net Question

Web Browser Control prevent Are you sure you want to leave this page

I have an application which is used to navigate to another page, a Kind of web browser, The problem is for some web pages it says "Are you sure you want to leave this page ? " dialogue. I want to remove it totally. It should start navigating without this dialogue. I tried this,

WebBrowser.ScriptErrorsSuppressed = True


Screenhot : http://image.prntscr.com/image/5d1adcbd60794f22b5ad7baf736b29f2.png

I have also tried to disable javascript but no luck. Any help would be appreciated.

Answer Source

The JavaScript onbeforeunload event is responsible to handle such messages. By setting it to null as:

window.onbeforeunload = null;

you can prevent its handlers code from running.