In regards to browser support, from Wikipedia:
Data URIs are currently supported by
the following web browsers:
- Gecko and its derivatives, such as Mozilla Firefox
- Opera
- KDE, through the KIO input/output system. This allows the KDE browser, Konqueror to support data URIs.
- Safari; although Safari's rendering engine, WebKit, is a derivative of Konqueror's KHTML engine, Mac OS X does not share the KIO slaves architecture so the implementations are not shared.
- Safari for the iPhone;
- Google Chrome
- Internet Explorer 8; Microsoft has limited support to certain "non-navigable" content, such as in tags and CSS rules, for security reasons, including concerns that JavaScript embedded in a data URI may not be interpretable by script filters such as those used by web-based email clients. Data URIs must be smaller than 32k.
- TheWorld Browser; is an IE shell browser which has a built-in support for Data URI scheme
IE does not handle the <object>
tag correctly, see here for more details. Briefly, you can't trust IE to display images from it.
The javascript:imageData
is also not well-supported, since it is used in a lot of cross site scripting attacks.
There are many discussions of this on the web, and they all come to the conclusion that there is no good universal way to embed images. If you only need to support a subset of browsers, the data uri may work, or a combination of data uri and javascript.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…