Commit e2888ba8456ac03a95b8c340b950e2079727ba01
1 parent
3de91564
修改检察院名称跳转问题
Showing
1 changed file
with
89 additions
and
20 deletions
FRControl/WebView.cs
... | ... | @@ -13,6 +13,7 @@ namespace FRControl |
13 | 13 | { |
14 | 14 | public partial class WebView : Form |
15 | 15 | { |
16 | + private Timer timer1 = null; | |
16 | 17 | public WebView() |
17 | 18 | { |
18 | 19 | SetWebBrowserFeatures(11); |
... | ... | @@ -69,25 +70,6 @@ namespace FRControl |
69 | 70 | htmlElement.SetAttribute("target", "_self"); |
70 | 71 | } |
71 | 72 | |
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 | - 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 | - } | |
90 | - | |
91 | 73 | this.webBrowser1.Document.Window.Error += new HtmlElementErrorEventHandler(Window_Error); |
92 | 74 | //获取网页的最大size |
93 | 75 | Size szba = new Size(webBrowser1.Document.Body.ScrollRectangle.Width, webBrowser1.Document.Body.ScrollRectangle.Height); |
... | ... | @@ -111,9 +93,89 @@ namespace FRControl |
111 | 93 | axIWebBrowser2.ExecWB(FRControl.ZoomBrowser.OLECMDID.OLECMDID_OPTICAL_ZOOM, |
112 | 94 | FRControl.ZoomBrowser.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, |
113 | 95 | xbili, IntPtr.Zero); |
96 | + | |
97 | + this.elem_Click(); | |
98 | + //HtmlElementCollection elementCollection = this.webBrowser1.Document.GetElementsByTagName("b"); | |
99 | + //if (null != elementCollection) | |
100 | + //{ | |
101 | + // foreach (HtmlElement elem in elementCollection) | |
102 | + // { | |
103 | + // if (elem.GetAttribute("className").ToString().Equals("lanmu")) | |
104 | + // { | |
105 | + // elem.SetAttribute("className", "lanmuc"); | |
106 | + // elem.Click += new HtmlElementEventHandler(elem_Click); | |
107 | + // } | |
108 | + | |
109 | + // //Console.WriteLine(elem.InnerHtml+",class="+ elem.GetAttribute("className").ToString()); | |
110 | + // //Console.WriteLine(elem.GetAttribute("class").ToString()); | |
111 | + // } | |
112 | + //} | |
113 | + } | |
114 | + | |
115 | + | |
116 | + | |
117 | + public void elem_Click() | |
118 | + { | |
119 | + timer1 = new Timer(); | |
120 | + timer1.Interval = 100; | |
121 | + timer1.Enabled = true; | |
122 | + timer1.Tick += new EventHandler(jcyEventProcessor);//添加事件 | |
123 | + | |
124 | + | |
125 | + //HtmlElement elem = (HtmlElement)sender; | |
126 | + //String url = "https://www.12309.gov.cn" + elem.GetAttribute("url").ToString(); | |
127 | + //this.webBrowser1.Navigate(url); | |
128 | + //Console.WriteLine(url); | |
129 | + //Console.WriteLine(elem.InnerHtml + ",class=" + elem.GetAttribute("className").ToString()+"url:"+ elem.GetAttribute("url").ToString()); | |
130 | + | |
114 | 131 | } |
115 | 132 | |
116 | - public void elem_Click(object sender, EventArgs e) | |
133 | + public void jcyEventProcessor(object sender, EventArgs e) | |
134 | + { | |
135 | + | |
136 | + HtmlElementCollection elementCollection = this.webBrowser1.Document.GetElementsByTagName("b"); | |
137 | + bool isLoad = false; | |
138 | + if (null != elementCollection) | |
139 | + { | |
140 | + //Console.WriteLine(isLoad); | |
141 | + foreach (HtmlElement elem in elementCollection) | |
142 | + { | |
143 | + if (elem.GetAttribute("className").ToString().Equals("lanmu")) | |
144 | + { | |
145 | + isLoad = true; | |
146 | + //elem.SetAttribute("className", "lanmuc"); | |
147 | + //elem.Click += new HtmlElementEventHandler(elem_Click); | |
148 | + } | |
149 | + } | |
150 | + | |
151 | + } | |
152 | + if (isLoad) | |
153 | + { | |
154 | + //Console.WriteLine(isLoad); | |
155 | + timer1.Stop(); | |
156 | + timer1.Tick -= new EventHandler(jcyEventProcessor); | |
157 | + timer1 = null; | |
158 | + | |
159 | + HtmlElementCollection elementCollections = this.webBrowser1.Document.GetElementsByTagName("b"); | |
160 | + if (null != elementCollections) | |
161 | + { | |
162 | + foreach (HtmlElement elem in elementCollections) | |
163 | + { | |
164 | + if (elem.GetAttribute("className").ToString().Equals("lanmu")) | |
165 | + { | |
166 | + elem.SetAttribute("className", "lanmuc"); | |
167 | + elem.Click += new HtmlElementEventHandler(jcyClick); | |
168 | + } | |
169 | + | |
170 | + Console.WriteLine(elem.InnerHtml+",class="+ elem.GetAttribute("className").ToString()); | |
171 | + Console.WriteLine(elem.GetAttribute("class").ToString()); | |
172 | + } | |
173 | + | |
174 | + } | |
175 | + } | |
176 | + } | |
177 | + | |
178 | + public void jcyClick(object sender, EventArgs e) | |
117 | 179 | { |
118 | 180 | HtmlElement elem = (HtmlElement)sender; |
119 | 181 | String url = "https://www.12309.gov.cn" + elem.GetAttribute("url").ToString(); |
... | ... | @@ -136,6 +198,13 @@ namespace FRControl |
136 | 198 | } |
137 | 199 | private void ReturnBtn_Click(object sender, EventArgs e) |
138 | 200 | { |
201 | + if (null != timer1) | |
202 | + { | |
203 | + timer1.Stop(); | |
204 | + timer1.Tick -= new EventHandler(jcyEventProcessor); | |
205 | + timer1 = null; | |
206 | + } | |
207 | + | |
139 | 208 | this.webBrowser1.Dispose(); |
140 | 209 | this.Close(); |
141 | 210 | } | ... | ... |