Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I let a user browse HTML/WebSite content without launching the browser (need an inline browser)?

I'm creating an app on Windows Phone 7 that lets folks read offline HTML content. Is there a way to show an inline browser or HTML viewing control?

like image 622
Scott Hanselman Avatar asked Aug 03 '10 08:08

Scott Hanselman


1 Answers

The WebBrowser control allows you to display arbitrary HTML.

There are two methods on the WebBrowser control you can use to display HTML:

  1. Navigate() will display the contents of a file located at the supplied URL. This file can be in IsolatedStorage or on a server.
  2. NavigateToString() will display the html string you give it.

In your case I'm guessing you'd use a WebClient object to download the webpage to offline storage, then the Navigate method to display it.

However, the benefit of NavigateToString is that you can munge the string on the way in to do some cool (or essential) stuff like style the page so it matches perfectly with the current phone theme, or catch all link clicks and make them pop in the external browser (otherwise they load in the very same WebBrowser control).

I've documented the details of styling and link clickery here.

like image 169
Ben Gracewood Avatar answered Sep 19 '22 21:09

Ben Gracewood