WebBrowser不显示图片. [英] WebBrowser Not Displaying pictures.

查看:344
本文介绍了WebBrowser不显示图片.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有一个Web浏览器,我试图用来显示使用MS Word构建的Manual.htm.本手册仅适用于我编写的应用程序.我已经尝试了所有将文件另存为HTML或Web页文档的MS Word保存功能.如果是从Internet Explorer中打开的文档,这将是文件正确显示的怪异部分(我什至保存了此网页,该网页在IE中都已正确显示,并尝试在webbrowser控件中使用此文件,但仍未显示图片).
但是从我的应用程序中,它将显示具有其格式的所有文本,但是在图片所在的位置显示空白区域.没有红色的X或任何表示图片有问题的东西.
我已经尝试过在搜索此类问题时发现的所有建议.我的系统完全更新了所有MS更新.我在32位笔记本电脑上运行Windows 7 Ultimate,Visual Studio Ultimate,VB.下面的代码是我上次使用webbrowser控件在代码中尝试过的代码.

Hi all,
I have a webbrowser I am trying to use to display a Manual.htm that is built using MS Word. This manual is for an aplication I have written. I have tried all the MS word save functions that save the file as a Html or web page document. This is the wierd part the document will show correctly if it is opened from Internet Explorer(I even saved this webpage that was displayed correctly in IE and tried using this file in the webbrowser control but it still did not show the pictures).
But from my application it will show all the text with it''s formating but a blank area is shown where the picture is. There is no red X or any thing that would represent the picture having a problem.
I have tryed all the suggestions I found in searches for this type problem. My system is completely up to date with all MS updates. I am running windows 7 ultimate, Visual Studio ultimate, VB, on a 32 bit laptop. The code below is what I last tried in the code using the webbrowser control.

sitepath = System.IO.Path.Combine("C:\Users\Curtis\Documents\Manual.html")
       Dim theStreamreader As New StreamReader(sitepath)
       Dim file As String = theStreamreader.ReadToEnd()
       'RichTextBox1.Text = file
       WebBrowser1.AllowNavigation = True

       WebBrowser1.DocumentText = file
       theStreamreader.Close()


我唯一能想到的就是导致此问题的Web浏览器或Visual Studio中的某些设置,但我找不到该设置.我还没有尝试发布应用程序,以查看发布后它是否仍然可以执行此操作,但是在调试时它应该像已发布的版本一样工作.

感谢您的帮助.

Curtis


The only thing I can think of is some setting either in the webbrowser or Visual studio that is causing this but I cannot find that setting. I have not tried publishing the application yet to see if it still done this after publishing but in debug it should work as in a published version.

Thanks for any help in this.

Curtis

推荐答案

请确保图像与HTML文档位于同一文件夹中,然后可以将相对路径与WebBrowser控件一起使用.不要使用Document.Text属性进行导航.使用WebBrowser.Navigate()方法.这样,WebBrowser知道"文档和图像在同一文件夹中.设置Document.Text属性不会告诉WebBrowser文件位于何处.

根据我对Word早期版本的经验,它创建了糟糕的HTML.如果您愿意,最好编写自己的HTML,或者访问 download.com [ ^ ]并找到其他所见即所得的编辑器.
Be sure that your images are in the same folder as your HTML documents, and you can then use relative paths with the WebBrowser control. Don''t use the Document.Text property for navigation. Use the WebBrowser.Navigate() method. This way the WebBrowser "knows" that the document and the images are in the same folder. Setting the Document.Text property does not tell the WebBrowser where your files are located.

From my experience with earlier versions of Word, it creates terrible HTML. You''d likely be better off to write your own HTML if you''re comfortable with it, or visit download.com[^] and find a different WYSIWYG editor.


0 )为什么不合并任何内容,为什么要呼叫Path.Combine?

1)WebBrowser控件要求图像文件名完全合格.换句话说,您不能使用"filename.jpg",而必须使用"C:\ myfolder \ filename.jpg".

0) Why are you calling Path.Combine when you''re not combining anything?

1) The WebBrowser control requires that image file names be fully qualified. In other words, you can''t use "filename.jpg" - you must instead us "C:\myfolder\filename.jpg".

It''s a major pain in the ass.


它不能将图片保存"在html文件中.它们可能位于同名的子文件夹中.尝试将其保存为"mht"文件,该文件应将图片嵌入浏览器可以显示的单个文件中.
It can''t save the pictures "in" a html file; they''re probably in a subfolder with the same name. Try saving it as a "mht" file, that should embed the pictures within a single file that the browser can display.


这篇关于WebBrowser不显示图片.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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