Setting img src to a data url via work does not work in IE8?

主宰稳场 提交于 2019-12-24 05:22:39

问题


When I attempt to set an image to use a data url via JavaScript (from this question), it does not appear to work in IE8.

The page in that first link has: <img id="foo" src="alphaball.png">
On line 25, this JavaScript code executes: document.getElementById('foo').src = img_src;

On all other browsers (including IE9b) this successfully changes the image from the alphaball to a picture of my head. On IE8, I see the alphaball very briefly, and then it is replaced with a missing image icon.

Is this a known issue? Is there a workaround for using data urls with IE8 and JavaScript?


回答1:


Internet Explorer versions before 9 do not support data URLs. There's an alternative mechanism that apparently kind-of works.

edit — actually I'm wrong; IE8 will support them as long as they're less than 32KB.

edit again — ok I found the article I was thinking about concerning the "MHTML" thing from Microsoft.



来源:https://stackoverflow.com/questions/4807622/setting-img-src-to-a-data-url-via-work-does-not-work-in-ie8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!