Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable popup in webbrowser-control

In my form, when i click webbrowser1, many window IE advertising opened.

I used my code:

webBrowser1.ScriptErrorsSuppressed = true;

But it does not work.

like image 834
user3508707 Avatar asked Mar 20 '23 22:03

user3508707


1 Answers

You can use this link

If here pop up means WebBrowser open a webpage in a new Internet Explorer, then please follow these steps to avoid such condition:

  1. Click WebBrowser in Windows Form design time, and open property window of WebBrowser.
  2. Add NewWindow event handler at Event tab of property window.
  3. Use these codes in the event handler, like:

    private void webBrowser1_NewWindow(object sender, CancelEventArgs e) { webBrowser1.Navigate(webBrowser1.StatusText); e.Cancel = true; }

Here, StatusText actually holds the URL of the target webpage original opened in Internet Explorer. Besides, e.Cancel = ture is to cancel the original action to open webpage in Internet Explorer.

like image 66
neel shah Avatar answered Mar 28 '23 19:03

neel shah