1

HTML of the page is

 <html>
    <head>
        <title>This is Title</title>
    </head>
    <body>
        <button  value="Hello World" onclick="test()"  style="width: 171px; height: 77px"></button>
    </body>
</html>
<script>
    function test() {
        window.close();
    }
</script>

WPF code is

BrowserWindow1.Navigate(TextBox1.Text)

When I click on the button on the browser. Browser control gives me this message

The web page you are viewing is trying to close the tab. Do you want to close this tab?

I want to handle this thing before prompting this message and after prompting this message and thus override the default functionality of browser control with mine functionality.

Manvinder
  • 4,495
  • 16
  • 53
  • 100
  • You can try that : `window.onbeforeunload` http://stackoverflow.com/questions/13443503/how-to-run-javascript-code-on-window-close however I am not sure if you can change a browser built in behavior. – Mehdi Karamosly Nov 06 '13 at 19:06

1 Answers1

1

Try handling WindowClosing event on the underlying WebBrowser ActiveX Control (here's how to get a hold of it with WPF version of WebBrowser). If that doesn't work, check this one.

Community
  • 1
  • 1
noseratio
  • 59,932
  • 34
  • 208
  • 486