Javascript Base64 DataURL 图像的大小限制是多少?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12637395/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 10:55:00  来源:igfitidea点击:

What is the size limit of a Base64 DataURL image?

javascripthtmlwebbase64

提问by Pierre

I would like to know what is the maximum length of a Base64 DataURL Image to be load in a browser?

我想知道要在浏览器中加载的 Base64 DataURL 图像的最大长度是多少?

Thanks!

谢谢!

采纳答案by Sirko

Citing MDN on this:

在此引用MDN

Length limitations

Although Mozilla supports data URIs of essentially unlimited length, browsers are not required to support any particular maximum length of data. For example, the Opera 11 browser limits data URIs to around 65000 characters.

长度限制

尽管 Mozilla 支持基本上无限长度的数据 URI,但浏览器不需要支持任何特定的最大数据长度。例如,Opera 11 浏览器将数据 URI 限制为大约 65000 个字符。

And caniuse.com, where you can also look up the support across browsers:

caniuse.com,您还可以在其中查找跨浏览器的支持:

Support in Internet Explorer 8 is limited to images and linked resources like CSS files, not HTML files. Max URI length in IE8 is 32KB. In IE9 JavaScript files are supported too and the maximum size limit set to 4GB.

Internet Explorer 8 中的支持仅限于图像和链接资源,如 CSS 文件,而不是 HTML 文件。IE8 中的最大 URI 长度为 32KB。在 IE9 中也支持 JavaScript 文件,并且最大大小限制设置为 4GB。

回答by Apurv

Not all browsers support the data URI scheme. IE7 and earlier doesn't support data uri's at all. IE8 has a 32k limit.

并非所有浏览器都支持数据 URI 方案。IE7 及更早版本根本不支持数据 uri。IE8 有 32k 的限制。

http://www.bennadel.com/blog/2002-Creating-Base64-Encoded-Data-URLs-For-Images-In-ColdFusion.htm

http://www.bennadel.com/blog/2002-Creating-Base64-Encoded-Data-URLs-For-Images-In-ColdFusion.htm