Commit c025ad82606497e2195b840150be7b026a7a8192

Authored by sh
1 parent 1dfe1556

修改检察院名称跳转问题

FRControl/WebView.Designer.cs
... ... @@ -50,6 +50,7 @@
50 50 this.webBrowser1.TabIndex = 0;
51 51 this.webBrowser1.Url = new System.Uri("http://xz.wh.hbjc.gov.cn/", System.UriKind.Absolute);
52 52 this.webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted_1);
  53 + this.webBrowser1.NewWindow += new System.ComponentModel.CancelEventHandler(this.webBrowser1_NewWindow);
53 54 //
54 55 // BodyPanel
55 56 //
... ...
FRControl/WebView.cs
... ... @@ -68,6 +68,25 @@ namespace FRControl
68 68 {
69 69 htmlElement.SetAttribute("target", "_self");
70 70 }
  71 +
  72 + HtmlElementCollection elementCollection = this.webBrowser1.Document.GetElementsByTagName("b");
  73 +
  74 + if (null != elementCollection)
  75 + {
  76 + foreach (HtmlElement elem in elementCollection)
  77 + {
  78 +
  79 + if (elem.GetAttribute("className").ToString().Equals("lanmu"))
  80 + {
  81 + elem.SetAttribute("className", "lanmuc");
  82 + }
  83 +
  84 + //Console.WriteLine(elem.InnerHtml+",class="+ elem.GetAttribute("className").ToString());
  85 + //Console.WriteLine(elem.GetAttribute("class").ToString());
  86 +
  87 + }
  88 + }
  89 +
71 90 this.webBrowser1.Document.Window.Error += new HtmlElementErrorEventHandler(Window_Error);
72 91 //获取网页的最大size
73 92 Size szba = new Size(webBrowser1.Document.Body.ScrollRectangle.Width, webBrowser1.Document.Body.ScrollRectangle.Height);
... ... @@ -212,5 +231,12 @@ namespace FRControl
212 231 }
213 232 return mode;
214 233 }
  234 +
  235 + private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
  236 + {
  237 + // 使其他浏览器无法捕获此事件
  238 + // 阻止了其他浏览器显示网页,而是采用WebBrowser打开网页
  239 + //e.Cancel = true;
  240 + }
215 241 }
216 242 }
... ...