Javascript Internet Explorer 和 Base64 图像显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10159500/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Internet Explorer and Base64 image display
提问by user1238012
In aim to manipulate more easily various images on client side with Javascript, I wrote a function on server side (in VB 2010) to convert a file into a base64 string that I send to the client.
为了使用 Javascript 在客户端更轻松地操作各种图像,我在服务器端(在 VB 2010 中)编写了一个函数,将文件转换为我发送给客户端的 base64 字符串。
When I tried it in Internet Explorer 8.0 with 3 different images, 1 portrait and 2 landscapes, I realized that only the portrait image was displayed entirely, meanwhile both landscape images were truncated (I can see just the upper part of the image).
当我在 Internet Explorer 8.0 中尝试使用 3 张不同的图像,1 张肖像和 2 张风景时,我意识到只有肖像图像完全显示,同时两个风景图像都被截断了(我只能看到图像的上部)。
I thought I had a bug in my conversion function, until I tried my local page with Firefox: every image is perfectly displayed by Firefox.
我以为我的转换功能有问题,直到我用 Firefox 尝试了我的本地页面:每个图像都被 Firefox 完美显示。
So there is my question: Is this a well-known bug of Internet Explorer ? If the answer is yes, Is there a well-known remedy for that well-known bug?
所以我的问题是:这是 Internet Explorer 的一个众所周知的错误吗?如果答案是肯定的,是否有针对该众所周知的错误的众所周知的补救措施?
回答by Ryan McGrath
IE8 can only do Base64 URI images up to 32kb in size. It's a marginally annoying limitation, but you can still get by with icons/etc. Keep in mind that Base64 encoded images are on average 33% more data sent down the pipe anyway, so it's... eh, y'know, use your judgement.
IE8 只能处理最大 32kb 的 Base64 URI 图像。这是一个有点烦人的限制,但您仍然可以使用图标/等。请记住,无论如何,Base64 编码的图像通过管道发送的数据平均多出 33%,所以它......呃,你知道,使用你的判断。
For anyone interested, it's also possible to make these work in IE6/7 (without, I might add, that 32kb limit...): http://venodesigns.net/2010/06/17/you-got-your-base64-in-my-css/
对于任何感兴趣的人,也可以在 IE6/7 中使这些工作(没有,我可能会补充说,32kb 限制......):http: //venodesigns.net/2010/06/17/you-got-your- base64-in-my-css/
回答by Myforwik
IE8 is limited to 32KB. One way around this is to just serve the images in 'tiles' where each tile is less than 32KB.
IE8 限制为 32KB。解决此问题的一种方法是仅在“图块”中提供图像,其中每个图块小于 32KB。