C# webbrowser中新窗口在Webbrowser内打开屏蔽网页JS错误

private void webbrowser1_documentcompleted(object sender, webbrowserdocumentcompletedeventargs e)
        {
            //将所有的链接的目标,指向本窗体
            foreach (htmlelement archor in this.webbrowser1.document.links)
            {
                archor.setattribute("target", "_self");
            }
            //将所有的form的提交目标,指向本窗体
            foreach (htmlelement form in this.webbrowser1.document.forms)
            {
                form.setattribute("target", "_self");
            }

        }
        // this.webbrowser1.scripterrorssuppressed = true;   //屏蔽js相关错误。。。
        private void webbrowser1_newwindow(object sender, canceleventargs e)
        {
            e.cancel = true;
        }

        private void form1_load(object sender, eventargs e)
        {
            webbrowser1.allowwebbrowserdrop = false;
            webbrowser1.webbrowsershortcutsenabled = false;
            webbrowser1.iswebbrowsercontextmenuenabled = false;
        }

你可能感兴趣的:(C#学习)