简体   繁体   中英

WP8 WebBrowser how to find out type of navigation

I have added a WebBrowser control on a page. If the user taps on any link in the WebBrowser I need to get the Uri of the request and load it in a new page. Im using WebBrowser class's Navigating event to get the url that is requested. To achieve what I need to do, I need to differentiate whether the navigation happens because of a link is clicked or by calling Navigate method or any redirection has happened. In iOS UIWebViewDelegate's shouldStartLoadWithRequest method passes UINavigation type as one of the arguments. This argument says whether the link is clicked or something else has happened like initial load or some redirection. How to find out this in WP8 WebBrowser control ?.

正如mztan所说,没有内置方法可以检测Windows Phone 8中WebBrowser控件上的url单击。

Set a Navigating event to the WebBrowser and NavigatingEventArgs(argument) gives you the uri which have to be converted to string.Check the below Code.

 private void webBrowser1_Navigating(object sender, NavigatingEventArgs e)
    {
      string val = e.Uri.ToString();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM