How can I display local HTML in a Windows web browser?

I want to use a web browser to present some multimedia information with locally stored HTML files. The problem is that it simply presents static content without any HTML elements, and also does not display images. Example code:

StreamReader reader = new StreamReader(TitleContainer.OpenStream("pathString")); webBrowser.NavigateToString(reader.ReadToEnd()); 
+4
source share
2 answers

The best way to do this is to copy the html file and images to the same directory in isolated storage (see http://msdn.microsoft.com/en-us/library/ff431811(v=vs.92).aspx ) Then you call

webBrowser1.Navigate(new Uri("<Location_of_html_file_in_isolatedStorage>", UriKind.Relative)) .

If the images and the html file are in the same directory in the isolated storage, relative links to your images in this format:

<img src="../YourImage.jpg"/>

Will work correctly.

+3
source

I donโ€™t think that the WebBrowser control could access any images that can be stored in isolated storage, so all the content you want to display you probably need to somehow embed into one html, which will probably require some js code (I'm not a js / html expert) that should be included in the control (IsScriptEnabled, if I remember correctly). Otherwise, it would be better to turn your HTML into XAML or just otherwise analyze it and display it by code.

0
source

Source: https://habr.com/ru/post/1386147/


All Articles