开发者

Load an embedded html file into a webrowser control and replace img tags to point to embedded images

开发者 https://www.devze.com 2023-03-14 14:15 出处:网络
I want to show a html document in a web browser control (WinForms). The html file should contain images, that are embedded resources.

I want to show a html document in a web browser control (WinForms). The html file should contain images, that are embedded resources.

How can I modify the html that is s开发者_如何学运维hown in the webbrowser to replace the src attribute of the img tags to somehow show the embedded resource without copying it into the file system?


You could use src="data:image/png;base64,.... and replace the .... with the base64 encoded string.

You'll need to replace the src="url" for the img tags in the given HTML, which means you would have to store the HTML somewhere on disk temporarily, so I guess doesn't solve the problem, unless you have access to the HTML.


As you know Data URI's have problem with older browsers (IE < 8) so :

  1. You can use MHTML manner to save your embedding images.

  2. You can make Data URI's with this kind of javascript.

0

精彩评论

暂无评论...
验证码 换一张
取 消