如何在 Windows Phone 网络浏览器中显示本地 HTML?

发布于 2024-12-21 03:51:17 字数 236 浏览 1 评论 0原文

我想使用网络浏览器通过本地存储的 HTML 文件来呈现一些多媒体信息。问题是它只显示静态内容,没有任何 HTML 元素,也不显示图像。示例代码是:

StreamReader reader = new StreamReader(TitleContainer.OpenStream("pathString"));
webBrowser.NavigateToString(reader.ReadToEnd());

I want to use a web browser to present some multimedia information with locally stored HTML files. The problem is that it just presents the static content without any HTML elements, and also doesn't show the images. The sample code is:

StreamReader reader = new StreamReader(TitleContainer.OpenStream("pathString"));
webBrowser.NavigateToString(reader.ReadToEnd());

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

把时间冻结 2024-12-28 03:51:18

我不认为 WebBrowser 控件可以访问可能存储在独立存储中的任何图像,因此您想要显示的所有内容 - 您可能需要以某种方式将其嵌入到单个 html 中,这可能需要一些 js 代码(我不是js/html专家),需要在控件中启用(IsScriptEnabled如果我没记错的话)。否则 - 最好将 HTML 转换为 XAML,或者只是解析它并通过代码显示它。

I don't suppose the WebBrowser control could get access to any images that might be stored in isolated storage, so all the content you want displayed - you would probably need to somehow embed it in a single html, which would probably require some js code (I am not a js/html expert), which needs to be enabled in the control (IsScriptEnabled if I remember correctly). Otherwise - it might be better to convert your HTML to XAML or just otherwise parse it and display it by code.

傲娇萝莉攻 2024-12-28 03:51:17

执行此操作的最佳方法是将 html 文件和图像复制到独立存储中的同一目录(请参阅:http://msdn.microsoft.com/en-us/library/ff431811(v=vs.92).aspx)。然后,您调用

webBrowser1.Navigate(new Uri("", UriKind.Relative))

如果图像和 html 文件位于isolatedStorage 中的同一目录中,则以下格式的图像相对链接:

将正常工作。

The best way to do this is to copy your 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 isolatedStorage, relative links to your images in this format:

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

Will work correctly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文