BASE64 in HTML is not working

为君一笑 提交于 2019-12-21 17:15:35

问题


I had tried all possible way to display image using base64 string. But none of them are working. I tested it on IE6,7, Firefox 3. Please tell me what is wrong with below code.

<head>

<STYLE type="text/css">
div.image {
  width:100px;
  height:100px;
  background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA...);
}
 </STYLE>
</head>
<body>
<img src="data:image/jpg;base64,968" />
<img alt="Embedded Image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." />
<script type="text/javascript"  src="data:text/javascript;base64,dmFyIHNjT2JqMSA9IG5ldyBzY3Jv..."></script>
<div class="image"></div>
</body>

回答1:


I tested it on IE6,7, Firefox 3

It just happens that none of these support data URIs (well, Firefox 3 does I think, just not very well). So you're doing nothing wrong.

If you need your background image to display in these browsers, just use traditional image files and url() instead.



来源:https://stackoverflow.com/questions/4791601/base64-in-html-is-not-working

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