Commit 73dbe327085831be41b40c6685024ed6d0c7cffe
1 parent
cf4ef99f
修改跳转链接,新增tag
Showing
1 changed file
with
25 additions
and
8 deletions
FRControl/WebView.cs
... | ... | @@ -69,7 +69,24 @@ namespace FRControl |
69 | 69 | { |
70 | 70 | htmlElement.SetAttribute("target", "_self"); |
71 | 71 | } |
72 | + HtmlElementCollection elementCollection = this.webBrowser1.Document.GetElementsByTagName("b"); | |
72 | 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 | + elem.Click += new HtmlElementEventHandler(elem_Click); | |
83 | + } | |
84 | + | |
85 | + //Console.WriteLine(elem.InnerHtml+",class="+ elem.GetAttribute("className").ToString()); | |
86 | + //Console.WriteLine(elem.GetAttribute("class").ToString()); | |
87 | + | |
88 | + } | |
89 | + } | |
73 | 90 | this.webBrowser1.Document.Window.Error += new HtmlElementErrorEventHandler(Window_Error); |
74 | 91 | //获取网页的最大size |
75 | 92 | Size szba = new Size(webBrowser1.Document.Body.ScrollRectangle.Width, webBrowser1.Document.Body.ScrollRectangle.Height); |
... | ... | @@ -114,19 +131,19 @@ namespace FRControl |
114 | 131 | |
115 | 132 | |
116 | 133 | |
117 | - public void elem_Click() | |
134 | + public void elem_Click(object sender, EventArgs e) | |
118 | 135 | { |
119 | - timer1 = new Timer(); | |
120 | - timer1.Interval = 100; | |
121 | - timer1.Enabled = true; | |
122 | - timer1.Tick += new EventHandler(jcyEventProcessor);//添加事件 | |
136 | + //timer1 = new Timer(); | |
137 | + //timer1.Interval = 100; | |
138 | + //timer1.Enabled = true; | |
139 | + //timer1.Tick += new EventHandler(jcyEventProcessor);//添加事件 | |
123 | 140 | |
124 | 141 | |
125 | - //HtmlElement elem = (HtmlElement)sender; | |
126 | - //String url = "https://www.12309.gov.cn" + elem.GetAttribute("url").ToString(); | |
127 | - //this.webBrowser1.Navigate(url); | |
142 | + HtmlElement elem = (HtmlElement)sender; | |
143 | + String url = "https://www.12309.gov.cn" + elem.GetAttribute("url").ToString(); | |
128 | 144 | //Console.WriteLine(url); |
129 | 145 | //Console.WriteLine(elem.InnerHtml + ",class=" + elem.GetAttribute("className").ToString()+"url:"+ elem.GetAttribute("url").ToString()); |
146 | + this.webBrowser1.Navigate(url); | |
130 | 147 | |
131 | 148 | } |
132 | 149 | ... | ... |