diff --git a/FRControl/WebView.Designer.cs b/FRControl/WebView.Designer.cs index 6a9acfb..04e7e80 100644 --- a/FRControl/WebView.Designer.cs +++ b/FRControl/WebView.Designer.cs @@ -50,6 +50,7 @@ this.webBrowser1.TabIndex = 0; this.webBrowser1.Url = new System.Uri("http://xz.wh.hbjc.gov.cn/", System.UriKind.Absolute); this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted_1); + this.webBrowser1.NewWindow += new System.ComponentModel.CancelEventHandler(this.webBrowser1_NewWindow); // // BodyPanel // diff --git a/FRControl/WebView.cs b/FRControl/WebView.cs index f406b79..1079865 100644 --- a/FRControl/WebView.cs +++ b/FRControl/WebView.cs @@ -68,6 +68,25 @@ namespace FRControl { htmlElement.SetAttribute("target", "_self"); } + + HtmlElementCollection elementCollection = this.webBrowser1.Document.GetElementsByTagName("b"); + + if (null != elementCollection) + { + foreach (HtmlElement elem in elementCollection) + { + + if (elem.GetAttribute("className").ToString().Equals("lanmu")) + { + elem.SetAttribute("className", "lanmuc"); + } + + //Console.WriteLine(elem.InnerHtml+",class="+ elem.GetAttribute("className").ToString()); + //Console.WriteLine(elem.GetAttribute("class").ToString()); + + } + } + this.webBrowser1.Document.Window.Error += new HtmlElementErrorEventHandler(Window_Error); //获取网页的最大size Size szba = new Size(webBrowser1.Document.Body.ScrollRectangle.Width, webBrowser1.Document.Body.ScrollRectangle.Height); @@ -212,5 +231,12 @@ namespace FRControl } return mode; } + + private void webBrowser1_NewWindow(object sender, CancelEventArgs e) + { + // 使其他浏览器无法捕获此事件 + // 阻止了其他浏览器显示网页,而是采用WebBrowser打开网页 + //e.Cancel = true; + } } }