hi,欢迎访问本站!
当前位置: 首页系统/服务器正文

WPF - WebBrowser 抑制js错误提示框

墨初 系统/服务器 1阅读

static void SuppressScriptErrors(WebBrowser webBrowser, bool hide)        {            webBrowser.Navigating += (s, e) =>                {                    var fiComWebBrowser = typeof(WebBrowser).GetField("_axIWebBrowser2", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);                    if (fiComWebBrowser == null)                        return;

                    object objComWebBrowser = fiComWebBrowser.GetValue(webBrowser);                    if (objComWebBrowser == null)                        return;

                    objComWebBrowser.GetType().InvokeMember("Silent", System.Reflection.BindingFlags.SetProperty, null, objComWebBrowser, new object[] { hide });                };        }

标签:
声明:无特别说明,转载请标明本文来源!