ie mhtml_MHTML –需要数据时:IE7及以下版本中的URI

news/2024/7/10 0:52:44 标签: python, java, js, html, vue
htmledit_views">
ie m<a class=html" width="403px" height="256px" style="outline: none;" />

ie mhtml

UPDATE: It's very important to have a closing separator in the MHTML document, otherwise there are known issues in IE7 on Vista or Windows 7. The details are here.

更新:在MHTML文档中有一个分隔符非常重要,否则在Vista或Windows 7的IE7中存在已知问题。详细信息在这里。

In the previous post I described what data: URIs are and how they are useful to reduce the number of HTTP requests. Now, the problem with data: URIs is that they are not supported by IE < 8. But, thanks to this article (in Russian), here's a way to work around that limitation: using MHTML for IE7 and under.

在上一篇文章中,我描述了什么数据:URI是什么以及它们如何减少HTTP请求的数量。 现在,数据存在问题:URI <IE <8不支持URI。但是,感谢本文(俄语),这是解决该限制的一种方法:将MHTML用于IE7及以下版本。

MHTML-什么? (MHTML-a-what?)

MHTML is MIME HTML, or if you insist on me spelling it out completely is like "Multipurpose Internet Mail Extensions HyperText Markup Language". In short it's HTML but like email with attachments. In one "multipart" email you can have several... hm, things - HTML version of the email, text-only version, attachment, another attachment...

MHTML是MIME HTML,或者如果您坚持要我完全将其拼写出来,就像“多用途Internet邮件扩展超文本标记语言”。 简而言之,它是HTML,但就像带有附件的电子邮件一样。 在一个“多部分”电子邮件中,您可以有多个...嗯,事情-电子邮件HTML版本,纯文本版本,附件,另一附件...

MHTML is the same but for HTML. In one file you put a bunch of stuff (e.g. image files) and you save on the precious HTTP requests.

MHTML相同,但HTML相同。 在一个文件中,您放了一堆东西(例如图像文件),然后保存了宝贵的HTTP请求。

MHTML范例 (MHTML example)

Let's check out an example. The HTML is actually not important, it's the CSS where we'll stick all our inline images. Once with data: sheme for all normal browsers and once with the mhtml: scheme for IE before 8.

让我们来看一个例子。 HTML实际上并不重要,它是CSS,我们将粘贴所有内嵌图像。 一次使用数据:sheme适用于所有普通浏览器,一次使用mhtml:方案(适用于8之前的IE)

The overall "template" would look like so:

整体“模板”如下所示:

/*
Content-Type: multipart/related; boundary="_ANY_SEPARATOR"
 
--_ANY_SEPARATOR
Content-Location:somestring
Content-Transfer-Encoding:base64
 
iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAIAA[...snip...]SuQmCC
--_ANY_SEPARATOR--
*/
 
#myid {
  /* normal browsers */
  background-image: url("data:image/png;base64,iVBORw0[...snip...]");
  /* IE < 8 targeted with the star hack */
  *background-image: url(mhtml:http://phpied.com/mhtml.css!somestring); 
}

The multipart stuff goes into a CSS comment. You then use data: URI scheme for all normal browsers. Then you use the star hack to target IE browsers before 8. For these browsers you give the URL of the CSS, exclamation and then a string that uniquely identifies the desired "part" in the multipart comment. Simple, eh? Didn't think so, but hey, it's not exactly rocket science.

多部分内容放入CSS注释中。 然后,对所有普通浏览器使用data:URI方案。 然后,您可以使用star hack将IE浏览器定位到8之前的版本。对于这些浏览器,您提供CSS的URL,感叹号,然后提供一个字符串,该字符串可在多部分注释中唯一标识所需的“部分”。 简单吧? 没这么认为,但是,嘿,这不是火箭科学。

包含更多部分的演示示例 (Demo example with more parts)

Check out a demo page that has two "parts" in the multipart MHTML comment.

签出一个演示页面,该页面在多部分MHTML注释中具有两个“部分”。

The HTML is noting special and the CSS goes like:

HTML值得注意,CSS类似于:

/*
Content-Type: multipart/related; boundary="_ANY_STRING_WILL_DO_AS_A_SEPARATOR"
 
--_ANY_STRING_WILL_DO_AS_A_SEPARATOR
Content-Location:locoloco
Content-Transfer-Encoding:base64
 
iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAIAAAA7ljmRAAAAGElEQVQIW2P4DwcMDAxAfBvMAhEQMYgcACEHG8ELxtbPAAAAAElFTkSuQmCC
--_ANY_STRING_WILL_DO_AS_A_SEPARATOR
Content-Location:polloloco
Content-Transfer-Encoding:base64
 
iVBORw0KGgoAAAANSUhEUgAAABkAAAAUBAMAAACKWYuOAAAAMFBMVEX///92dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnYvD4PNAAAAD3RSTlMAACTkfhvbh3iEewTtxBIFliR3AAAAUklEQVQY02NgIBMwijgKCgrAef5fkHnz/y9E4kn+/4XEE6z/34jEE///A4knev7zAwQv7L8RQk40/7MiggeUQpjJff+zIpINykbIbhFSROIRDQAWUhW2oXLWAQAAAABJRU5ErkJggg==
--_ANY_STRING_WILL_DO_AS_A_SEPARATOR--
*/
 
#test1 {
  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAIAAAA7ljmRAAAAGElEQVQIW2P4DwcMDAxAfBvMAhEQMYgcACEHG8ELxtbPAAAAAElFTkSuQmCC"); /* normal */
  *background-image: url(mhtml:http://phpied.com/files/mhtml/mhtml.css!locoloco); /* IE < 8 */
}
 
 
#test2 {
  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAUBAMAAACKWYuOAAAAMFBMVEX///92dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnYvD4PNAAAAD3RSTlMAACTkfhvbh3iEewTtxBIFliR3AAAAUklEQVQY02NgIBMwijgKCgrAef5fkHnz/y9E4kn+/4XEE6z/34jEE///A4knev7zAwQv7L8RQk40/7MiggeUQpjJff+zIpINykbIbhFSROIRDQAWUhW2oXLWAQAAAABJRU5ErkJggg=="); /* normal */
  *background-image: url(mhtml:http://phpied.com/files/mhtml/mhtml.css!polloloco); /* IE < 8 */
}
 
div {
  width: 100px;
  height: 100px;
  font: bold 24px Arial;
}

退税 (Drawback)

In addition to the drawbacks of data: URIs (bigger CSS, small CSS change invalidates your cached inline images), this method has the obvious drawback that the inline images are repeated twice. But sometimes... a person's gotta do what a person's gotta do 😉

除了数据的缺点:URI(较大CSS,小CSS更改会使您缓存的嵌入式图像无效)之外,此方法还具有明显的缺点,即嵌入式图像重复两次。 但是有时候...一个人必须做的事一个人必须做的事😉

Tell your friends about this post on Facebook and Twitter

在Facebook和Twitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/

ie mhtml


http://www.niftyadmin.cn/n/1307271.html

相关文章

100句十分精辟的人生格言

100句十分精辟的人生格言 1、生活是一面镜子。你对它笑&#xff0c;它就对你笑&#xff1b;你对它哭&#xff0c;它也对你哭。 2、活着一天&#xff0c;就是有福气&#xff0c;就该珍惜。当我哭泣我没有鞋子穿的时候&#xff0c;我发现有人却没有脚。 3、人生是个圆&#xff0c…

100句富有哲理的人生格言

100句富有哲理的人生格言 1、人之所以有一张嘴&#xff0c;而有两只耳朵&#xff0c;原因是听的要比说的多一倍。 2、哲人无忧&#xff0c;智者常乐。并不是因为所爱的一切他都拥有了&#xff0c;而是所拥有的一切他都爱。 3、泪水和汗水的化学成分相似&#xff0c;但前者只能为…

SSH2三大框架整合出错(一)

usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop } 2013-12-1 22:01:15 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.27 using APR versi…

HTTPS迁移:Dreamhost上托管的WordPress博客

I use Dreamhost. Have been since 2008. If youre not using Dreamhost... well, go sign up and heres $50 off of the $97 yearly plan. 我使用Dreamhost。 自2008年以来一直。如果您不使用Dreamhost ...那么&#xff0c;快去注册吧&#xff0c;这是$ 97年度计划的$ 50折扣。…

SSH2三大框架整合出错(二)

usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop } 2013-12-1 22:29:26 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.27 using APR versi…

智能图像处理及应用下载_智能浏览器不会下载不需要的图像

智能图像处理及应用下载We ofter complain about browsers, browser inconsistencies, quirks, hickups, the list goes on. Lets say something nice to them, and hope for good karma &#x1f642; 我们经常抱怨浏览器&#xff0c;浏览器不一致&#xff0c;怪癖&#xff0c…

PEAR :: Structures_DataGrid列格式化程序的建议

This posting outlines a proposal for an addition to the PEAR package Structures_DataGrid. More specifically it concerns the formatter method of the Structures_DataGrid_Column class. 这篇文章概述了添加PEAR包Structures_DataGrid的建议。 更具体地说&#xff0c;…

SSH2三大框架整合出错(三)

usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help | start | stop } 2013-12-1 22:48:33 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.27 using APR versi…