问题
I need to create a page with all images and CSS in it, so it would be only one file.
I know that there is something like MHT (IE web archive), BUT there is problem. It works only in IE and Opera, not in FF. And i need my page to be working in all IEs (6+), Opera and FF. I know there is a way to encode my images in base64 and I also know, that IE 6 and 7 does not support data URLs. I've seen Dean Edward's trick for IE 6 and 7 but it works only with PHP support. And I can't use PHP, so this isn't working for me.
So, is there any way to create this kind of page? Please don't give me answers like "who is using IE6 today" or "install chrome frame". I know all this, but I need it to be working this way.
Thanks for the answer!
回答1:
There is no cross-browser way to integrate all resources into one HTML file.
Your best bet is probably to serve a .MHT file for IE, and one with data:
URIs for Firefox et al.
In some situations, a viable compromise may be serving a ZIP file that contains all resources, referenced using relative URLs. The user just has to unpack it, and can view it locally.
回答2:
I can only think of one solution that will work in all browsers, and that is building an image from html elements, but it will be very much work to do so (per pixel or other strategy). Maybe jQuery can help a little. Also this might slow IE6 down (even more than normal...)
example: http://jsfiddle.net/huSq3/1/
I know it isn't much of a solution but I had to mention it. Now I'm thinking of it maybe you can use the canvas tag in combination of this javascript library for IE and draw the images to that via javascript.
回答3:
Maybe you could use html conditional comments to decide which solution to use between MHT, data url, or any other partially supported solution...
回答4:
If you are OK with the base 64 string in the image tag, then just hardcode it, then you do not need php
来源:https://stackoverflow.com/questions/5663855/images-in-one-file-under-ie6-without-php