.net – How to force Web Browser control to always open web page in the same window

netwebbrowser-controlwinforms

I need to use web browser in my application as it keeps repetitive tasks from employees, but there is a problem with javascript that opens a new window in IE after clicking on anchor. How do I tell web browser control to "open new window" where I want it to be opened? For example in the other web browser control?

Best Answer

I found a simple solution that works.

private void WebBrowser1_NewWindow(object sender, System.ComponentModel.CancelEventArgs e) {
    e.Cancel = true;
    WebBrowser1.Navigate(WebBrowser1.StatusText);
}