webbrowser打开新窗口事件+=

测试可用:       
 private void SaveSnapshot_Click(object sender, EventArgs e)
        {
            this.webBrowser1.Navigate(txturl.Text);
 
            this.webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);  // 增加网页加载完成事件处理函数
            this.webBrowser1.NewWindow += new CancelEventHandler(webBrowser_NewWindow);

        }

        void webBrowser_NewWindow(object sender,CancelEventArgs e) {

            string url=((WebBrowser)sender).StatusText;
            this.webBrowser1.Navigate(url);
            e.Cancel = true;
        }
posted @ 2013-08-27 09:21  沧海一滴  阅读(1401)  评论(0编辑  收藏  举报