Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore script errors in Webbrowser

Tags:

browser

c#

What happens when I close my app, which uses webbrowser. The following url uses flash player.

alt text

Everything works fine. This error shows on app close. How do I ignore it?

like image 416
John black Avatar asked Oct 15 '25 14:10

John black


1 Answers

I know it's too late, but I feel I have a smart answer for this issue.

Use this, it's working for me on a fly. :)

webBrowser.ScriptErrorsSuppressed = true;

If it's not working, we can use different methods like showing a confirmation box (Ex: This windows want to close do you want to continue Yes/ No)

[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
    static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

[DllImport("user32.dll")]
        private static extern bool SetForegroundWindow(IntPtr hWnd);

 private void TimerPopUp_Tick(object sender, EventArgs e)
        {
            IntPtr hWnd1 = FindWindowByCaption(IntPtr.Zero, "Web Browser");

            if (hWnd1 != IntPtr.Zero && SetForegroundWindow(hWnd1))
            {
                SendKeys.Send("{Enter}");
            }

        }

If there are any errors, see this link.

like image 181
Avneesh Srivastava Avatar answered Oct 18 '25 03:10

Avneesh Srivastava