程序代码
代码如下 | 复制代码 |
private void Form1_Load(object sender, EventArgs e) { webBrowser1.Navigate("about:blank"); //必需,否则WebBrowser.ActiveXInstance值为null SHDocVw.WebBrowser wb = (SHDocVw.WebBrowser)webBrowser1.ActiveXInstance; wb.BeforeNavigate2 += delegate(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel) { if (PostData != null) { string data = Encoding.ASCII.GetString(PostData as byte[]); if (data.IndexOf("t=") == -1) { data = "t=" + DateTime.Now.Ticks.ToString() + "&" + data; SHDocVw.WebBrowser browser1 = pDisp as SHDocVw.WebBrowser; if (browser1 != null) { Cancel = true; browser1.Navigate(URL.ToString(), Flags, TargetFrameName, Encoding.ASCII.GetBytes(data), Headers); } } } }; } |
时间: 2024-09-13 23:53:45