//跳转前的地址 private void WebBrowser_BeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel) { String strUri = (URL == null ? "Null" : URL.ToString()); MessageBox.Show("post" + strUri); }
XAML代码: <WebBrowser x:Name="browser"/> C#代码: browser.Navigated += new NavigatedEventHandler(browser_Navigated); browser.Navigate(new Uri("http://www.microsoft.com")); //省略... void browser_Navigated(object sender, NavigationEventArgs e) {
string url=e.Uri.ToString();//这里是broswer的url }