通过差异对比DocumentText URL设置在Forms.WebBrowser控制内容 [英] Differences setting content in Forms.WebBrowser control via DocumentText vs. Url

查看:226
本文介绍了通过差异对比DocumentText URL设置在Forms.WebBrowser控制内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我产生一些HTML和有它在一个字符串,然后说:

If I generate some HTML and have it in a string and then say:

myWebBrowser.DocumentText = string;



这似乎只是正常工作,但没有任何图像负荷(我得到的破碎的形象图形)的

It seems to work just fine, except none of the images load (I get the broken image graphic).

但是,如果我写的字符串的文件,然后说:

If, however, I write the string to a file and then say:

myWebBrowser.Url = new Uri("file://myfile.html");



一切工作就好了。

Everything works just fine.

我的问题是,什么是这里的井盖是根据不同回事?我在上述两种情况下(通过RClick->查看源文件)的路径,图像是相同的验证,所有的图片做的,确实存在。

My question is, what's going on under the covers here that is different? I've verified in both cases that the path to the images (via RClick->View Source) is the same and that all the images do, indeed, exist.

在这两种情况下,HTML是完全一样的。

In both cases the HTML is exactly the same.

这可以在此被有何启示是赞赏。谢谢!

Any light that could be shed on this would be appreciated. Thanks!

推荐答案

在文本文件中的URL是相对于你在页面最有可能的。随着当你保存的网址是成为绝对的文件说。您可能需要添加一个
<基本href =Your.html/>
标记您的标记,以在Web浏览器中的图像可见。

The urls in the document text are most likely relative to the page you are on. With that said when you save to a file the urls are made absolute. You may want to add a <base href="Your.html" /> tag to your markup to make the image visible in the web browser.

WebBrowser控件解决那些相对图像,他们的位置,并相应地显示出来。

The WebBrowser control resolves those relative images to their location and displays them accordingly.

这篇关于通过差异对比DocumentText URL设置在Forms.WebBrowser控制内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆