以下是代码片段: #region 当右键点击在新窗口打开时打开新窗口 void Form1_NewWindow3(ref object ppDisp, ref bool Cancel, uint dwFlags, string bstrUrlContext, string bstrUrl) { int index = bstrUrl.LastIndexOf("/"); int index_s = bstrUrl.Length - 5; string domain = bstrUrl.Substring(index+1, index_s - index-1); Cancel = true; try { System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser(); string strurl = webBrowser1.Document.ActiveElement.GetAttribute("href"); wb.Url = new System.Uri(strurl, System.UriKind.Absolute);
tabControl1.TabPages.Add(domain); wb.Dock = DockStyle.Fill; tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(wb); } catch { } } #endregion |