简体   繁体   中英

Opening docx file in Windows Phone 8 webbrowser control

I am loading a URL in webbrowser control of windows phone 8. When I click on the docx file which is available to download from the site, It is not getting downloaded or opened. It just keeps loading. Is there anyway to open docx file in webbrowser control or to download the docx file and open through IE10 browser of WP8?

You'll need to attach to the Navigating event of the WebBrowser ( reference ). In that event, you'll need to look for URLs that you want to handle and then launch them directly, and then cancel the Navigation. Something like this untested code.

void web_Navigating(object sender, NavigatingEventArgs e) {
   string url = e.Uri.ToString();
   if (url.EndsWith("docx")) {
      Launcher.LaunchUriAsync(url);
      e.Cancel = true;
      return;
   }
 } 

您可以通过传递这样的网址轻松打开它

await Launcher.LaunchUriAsync(new Uri("http://www.abundantcode.com/mydoc.docx"));

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