C#中的webBrowser控制元件,如何讓它點選所有連結都是在當前視窗開啟
阿新 • • 發佈:2019-01-04
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"); } } private void webBrowser1_NewWindow(object sender, CancelEventArgs e) { e.Cancel = true; } WebBrowser1.AllowWebBrowserDrop=false; WebBrowser1.WebBrowserShortcutsEnabled=false; WebBrowser1.IsWebBrowserContextMenuEnabled=false