哪位知道?凡是要说webBrowser1.ScriptErrorsSuppressed = true;这个方法的请再考虑一下,这招不管用

解决方案 »

  1.   

    你可以在Visual  Studio中进行设置下的。
    Debug > Options and Settings > Debugging > Just-In-Time > Uncheck "Script":http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-55-85/5342.DebuggerSettings.PNG
      

  2.   

    你可以在Visual  Studio中进行设置下的。
    Debug > Options and Settings > Debugging > Just-In-Time > Uncheck "Script":
      

  3.   

      using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using System.Runtime.CompilerServices;
    using System.Collections;
    using mshtml;namespace WindowsFormsApplication28
    {
        public class WebBrowserEx : System.Windows.Forms.WebBrowser
        {
            #region WebBrowserSiteEx Class
          
                public WebBrowserSiteEx(WebBrowserEx webBrowser)
                    : base(webBrowser)
                {
                    //_webBrowser = webBrowser;
                }            #region IServiceProvider Members
                public int QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject)
                {
                    if (guidService == IID_IInternetSecurityManager&&riid == IID_IInternetSecurityManager)
                    {
                        ppvObject = Marshal.GetComInterfaceForObject(this,typeof(IInternetSecurityManager));
             
                #region IInternetSecurityManager Members
                public unsafe int SetSecuritySite(void* pSite)
                {
                    return Constants.INET_E_DEFAULT_ACTION;
                }            public unsafe int GetSecuritySite(void** ppSite)
                {
                    return Constants.INET_E_DEFAULT_ACTION;
             IInternetSecurityManager* pInetSecMgr;
    HRESULT hr = CoCreateInstance(CLSID_InternetSecurityManager, NULL, CLSCTX_ALL,
             
                        // if ( cbPolicy >= sizeof (DWORD))
                        //  {
                        //     *(DWORD*) pPolicy = dwPolicy;
                        //      return S_OK;
                        //  } 
                        //   else 
                        // {
                        //      return S_FALSE;
                        //   }
                        // }
                        //*/                    *((int*)pPolicy) = (int)Constants.UrlPolicy.URLPOLICY_ALLOW;
           
                        return Constants.S_OK;
                    }            }            public unsafe int QueryCustomPolicy(string pwszUrl, void* guidKey, byte** ppPolicy, int* pcbPolicy, byte* pContext, int cbContext, int dwReserved)
                {
                    return Constants.INET_E_DEFAULT_ACTION;
                }            public int SetZoneMapping(int dwZone, string lpszPattern, int dwFlags)//添加受信任或者不受信任或者本地站点
                {
                    /*
                     IInternetSecurityManager * pSecurityManager = NULL;
                    HRESULT HRESULT = S_OK;                :: CoInitialize的(NULL);
                    HRESULT = CoCreateInstance的(CLSID_InternetSecurityManager, 
                                              NULL, 
                                              CLSCTX_INPROC_SERVER,
                                              IID_IInternetSecurityManager,
                                              (无效**)&pSecurityManager的);
                    
                    (SUCCEEDED(HRESULT))
                    {
                      HRESULT = pSecurityManager> SetZoneMapping(URLZONE_ESC_FLAG | URLZONE_TRUSTED的,
                                                               “L”http://msdn.microsoft.com
                                                               SZM_CREATE);
                    
                      pSecurityManager  - >发行();
                    }
                    :: CoUninitialize的();                 */
                    return Constants.INET_E_DEFAULT_ACTION;
                }            public unsafe int GetZoneMappings(int dwZone, void** ppenumString, int dwFlags)
                {
                    return Constants.INET_E_DEFAULT_ACTION;
                }
                #endregion            #region IDocHostShowUI 成员
                //void ShowMessage([In, ComAliasName("ExtendedWebBrowser2.UnsafeNativeMethods.wireHWND")] ref _RemotableHandle hwnd, [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrText, [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrCaption, [In] uint dwType, [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrHelpFile, [In] uint dwHelpContext, [ComAliasName("ExtendedWebBrowser2.UnsafeNativeMethods.LONG_PTR")] out int plResult);
                //[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
                public void ShowMessage(ref _RemotableHandle hwnd, string lpstrText, string lpstrCaption, uint dwType, string lpstrHelpFile, uint dwHelpContext, out int plResult)
                {
                    plResult = 0;
                    if (lpstrText == "Hello222222")
                    {
                        if (MessageBox.Show("是否要屏蔽Alert对话框", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            MessageBox.Show("屏蔽鸟", "屏蔽鸟");
                            return;
                        }
                        else
                        {
                            //
                        }
                    }
                    throw new NotImplementedException();
                    // MessageBox.Show("sfdasdfas");
                }            public void ShowHelp(ref _RemotableHandle hwnd, string pszHelpFile, uint uCommand, uint dwData, tagPOINT ptMouse, object pDispatchObjectHit)
                {
                    throw new NotImplementedException();
                }            #endregion
            }
            #endregion WebBrowserSiteEx Class        private WebBrowserSiteEx _site;        public WebBrowserEx()
            {        }        //protected override WebBrowserSiteBase CreateWebBrowserSiteBase();
            protected override WebBrowserSiteBase CreateWebBrowserSiteBase()//实现有从 WebBrowser 和 WebBrowser.WebBrowserSite 类继承的类
            //非托管 WebBrowser ActiveX 控件使用受保护的 CreateWebBrowserSiteBase 方法检索由 
            //WebBrowser.WebBrowserSite 类实现的扩展性接口。 重写 CreateWebBrowserSiteBase 方法以返回自己的从 WebBrowser.WebBrowserSite 类继承的类的实例。
            {
                if (_site == null)
                    _site = new WebBrowserSiteEx(this);
                return _site;
            }
        }    [ComImport]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        [Guid("6d5140c1-7436-11ce-8034-00aa006009fa")]
        public interface IServiceProvider
        {
            [PreserveSig]
            int QueryService(ref Guid guidService, ref Guid riid, out IntPtr ppvObject);
        }
        #region IDocHostShowUI
        [StructLayout(LayoutKind.Explicit, Pack = 4)]
        public struct __MIDL_IWinTypes_0009
        {
            // Fields 
            [FieldOffset(0)]
            public int hInproc;
            [FieldOffset(0)]
            public int hRemote;
        }    [StructLayout(LayoutKind.Sequential, Pack = 4)]
        public struct _RemotableHandle
        {
            public int fContext;
            public __MIDL_IWinTypes_0009 u;
        }    [StructLayout(LayoutKind.Sequential, Pack = 4)]
        public struct tagPOINT
        {
            public int x;
            public int y;
        }    [ComImport, Guid("C4D244B0-D43E-11CF-893B-00AA00BDCE1A"), InterfaceType((short)1)]
        public interface IDocHostShowUI
        {
            [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
            void ShowMessage([In, ComAliasName("ExtendedWebBrowser2.UnsafeNativeMethods.wireHWND")] ref _RemotableHandle hwnd, [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrText, [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrCaption, [In] uint dwType, [In, MarshalAs(UnmanagedType.LPWStr)] string lpstrHelpFile, [In] uint dwHelpContext, [ComAliasName("ExtendedWebBrowser2.UnsafeNativeMethods.LONG_PTR")] out int plResult);
            [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
            void ShowHelp([In, ComAliasName("ExtendedWebBrowser2.UnsafeNativeMethods.wireHWND")] ref _RemotableHandle hwnd, [In, MarshalAs(UnmanagedType.LPWStr)] string pszHelpFile, [In] uint uCommand, [In] uint dwData, [In] tagPOINT ptMouse, [Out, MarshalAs(UnmanagedType.IDispatch)] object pDispatchObjectHit);
        }
        #endregion
        //---------------------------    //---------------------------