当你要使用data URI scheme的时候,你会发现,虽然他可以使用在绝大多数浏览器上,但无法再IE6和IE7上工作。不过值得庆幸的这一篇文章给我们带来了解决办法:http://webo.in/articles/habrahabr/46-cross-browser-data-url/
什么是MHTML?
单个文件网页可将网站的所有元素(包括文本和图形)都保存到单个文件中。这种封装使您可将整个网站发布为单个内嵌 MIME (MIME:通过 Internet 连接传递多媒体资源的一列标准。MIME 类型通知程序对象所包含的内容(如图形、声音或视频)的聚合HTML文档(MHTML)文件,或将整个网站作为一个电子邮件或附件发送。
Internet Explorer 4.0及更高版本支持此格式。
使用MHTML支持dat URI scheme的例子
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /* Content-Type: multipart/related; boundary="_ANY_STRING_WILL_DO_AS_A_SEPARATOR" --_ANY_STRING_WILL_DO_AS_A_SEPARATOR Content-Location:the9 Content-Transfer-Encoding:base64 /9j/4AA....+b0//2Q== (这里是base64编码) */ #the9{ background-image: url("data:image/png;base64/9j/4AA....+b0//2Q=="); /* normal */ *background-image: url(mhtml:http://www.zhangjingwei.com/demo/scheme/style.css!the9); width:300px; height:300px; color:#F00; font-weight:900; } |
http://www.zhangjingwei.com/demo/scheme/index.html