讓彈出窗口在自己的瀏覽器中顯示

private void webBrowser1_NewWindow(object sender, CancelEventArgs e)//點擊,如果本鏈接是彈出新窗口,事件就會自動截獲。
        {
            try
            {
                string strurl = webBrowser1.Document.ActiveElement.GetAttribute("href");
                if (!strurl.Contains("://"))
                    strurl = "http://" + strurl;
                this.webBrowser1.Url = new System.Uri(strurl, System.UriKind.Absolute);
                e.Cancel = true;
            }
            catch { }
        }
//代碼主體意思是,獲取截獲的Url地址,重新綁定給webbrower瀏覽器控件,然後把跳轉的cancel=true,意思就是不讓它彈出IE等默認瀏覽器。

發佈了13 篇原創文章 · 獲贊 0 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章