copy语法不正确_正确的MHTML语法

news/2024/7/19 14:24:22 标签: java, python, php, mysql, js
copy语法不正确

copy语法不正确

Reducing the number of HTTP requests is a must, sprites are cool, but a pain to maintain, so there come data URIs (for all browsers) and MHTML (IE6 and 7). I've talked about these things on this blog to a point where the blog comes up in top 10 results in search engines for queries like "mhtml" and "data url". Therefore I think it's my duty to clarify a point for the good of the mankind 🙂

减少HTTP请求的数量是必须的, sprite很酷,但是维护起来很麻烦,因此出现了数据URI (对于所有浏览器)和MHTML (IE6和7)。 我已经在此博客上谈论了这些事情,以至于该博客在搜索引擎中对“ mhtml”和“ data url”之类的查询排在前10位。 因此,我认为有责任澄清人类的利益

MHTML works in IE6 and IE7 even in the deadly IE7/Vista and IE7/Win7 combos

MHTML即使在致命的IE7 / Vista和IE7 / Win7组合中也可以在IE6和IE7中使用

In the community we've long considered MHTML in IE7/Vista a problem and I've personally come up with complex voodoo workarounds how to mitigate the issue and still make use of the technique. Turns out the whole problem all the time was a small syntax glitch.

在社区中,我们长期以来一直将IE7 / Vista中的MHTML视为一个问题,我亲自提出了复杂的voodoo解决方法,以减轻问题并仍然使用该技术。 原来,整个问题一直都是一个小的语法故障。

Pointed by a comment at a previous post all we ever needed was to close the boundary delimiter and add two dashes at the end. The double-dash of doom as I like to call them since I've spent so much time wrestling.

在上一篇文章中,通过评论指出,我们所需要的只是关闭边界定界符,并在末尾添加两个破折号。 因为我花了很多时间搏斗,所以我喜欢称他们为厄运双破折号

So let's take a look at the syntax.

因此,让我们看一下语法。

Update: Also check this comment for additional insight from Vincent, Aaron and _cphr_ regarding double line break of doom

更新:还请检查此注释,以获取来自Vincent , Aaron和_cphr_的关于双行破灭的更多见解

一部分(One part)

MHTML is a multi-part document. One document containing several parts. One part looks like this:

MHTML是一个包含多个部分的文档。 一个包含多个部分的文档。 一部分看起来像这样:

Content-Location: myimage
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSU....U5ErkJggg==

In other words it has headers, base64-encoded content and two empty lines to divide them.

换句话说,它具有标头,base64编码的内容和两个用于分隔它们的空行。

多部分 (Multi parts)

The different parts in the document are divided by a separator string. And at the top of the document you define what this separator is. Anything you like. So

文档中的不同部分由分隔符字符串分隔。 然后在文档顶部定义此分隔符是什么。 你喜欢的都可以。 所以

Content-Type: multipart/related; boundary="MYSEPARATOR"

--MYSEPARATOR

[here comes part one]

--MYSEPARATOR

[here's part two]

--MYSEPARATOR--

Did you notice -- at the very end? Yes, this is the double-dash of doom. Forget it and you get IE7/Vista problems (only on cached documents) and permanent hair loss. The thing is that in IE6 and other IE7s you can omit the whole last separator and it's all good. So historically you never needed it, but come Vista and Win7 and problems start.

你有没有注意到--在最后? 是的,这是厄运的双破折号。 忘记它,您会遇到IE7 / Vista问题(仅适用于缓存的文档)和永久脱发。 问题是在IE6和其他IE7中,您可以省略整个最后的分隔符,这一切都很好。 从历史上讲,您从不需要它,但是Vista和Win7出现了问题。

现在都在一起了 (All together now)

Finally, let's see the whole thing, a whole CSS file, including the way you refer to the parts later on in the CSS.

最后,让我们看到整个内容,一个完整CSS文件,包括稍后在CSS中引用各部分的方式。

/*
Content-Type: multipart/related; boundary="MYSEPARATOR"
 
--MYSEPARATOR
Content-Location: myimage
Content-Transfer-Encoding: base64
 
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAD....U5ErkJggg==

--MYSEPARATOR
Content-Location: another
Content-Transfer-Encoding: base64
 
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAA....U5ErkJggg==

--MYSEPARATOR--
*/
.myclass {
    background-image:url(mhtml:http://example.org/styles.css!myimage);
}
.myotherclass {
    background-image:url(mhtml:http://example.org/styles.css!another);
}

更新了PHP类 (Updated PHP class)

Previously when I fought IE7/Vista I came up with a PHP class that would take some images and create "data sprites" on the fly, creating two different versions - one with data URIs and one with MHTML, depending on the browser. The old code is here.

以前,当我与IE7 / Vista作战时,我想到了一个PHP类,该类可以拍摄一些图像并动态创建“数据精灵”,从而创建两个不同的版本-一个版本带有数据URI,另一个版本带有MHTML,具体取决于浏览器。 旧代码在这里。

Now, I've updated it (basically just deleted serious portions of it that dealt with Vista) and put it up on github. Right here.

现在,我已经对其进行了更新(基本上只是删除了涉及Vista的重要部分),并将其放在github上。 就在这里。

更新的测试页 (Updated test pages)

  • Updated test page from the original MHTML article with the double dash of doom correction. Just the CSS.

    更新了原始MHTML文章中的测试页,并带有双倍的厄运校正。 只是CSS 。

  • Test page for the DataSprites php class. Just the CSS (changes based on the User-Agent)

    DataSprites php类的测试页。 只是CSS (基于User-Agent的更改)

Thanks for reading, that's about it. Now off I go to correct the older posts, catch ya later 🙂

感谢您的阅读,仅此而已。 现在关闭,我去纠正较旧的帖子,以后再抓ya

Tell your friends about this post on Facebook and Twitter

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

翻译自: https://www.phpied.com/the-proper-mhtml-syntax/

copy语法不正确


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

相关文章

but the supplied types were (flex.messaging.io.amf.ASObject) and converted to (null).

1、错误描述 [RPC Fault faultString"Cannot invoke methodsaveOrUpdate." faultCode"Server.ResourceUnavailable"faultDetail"The expected argument types are(com.***.***.model.****) but thesupplied types were (flex.messaging.io.amf.ASObj…

2010年欧洲巡回赛

So its been pretty quiet around here. Im still alive and very much so. Just awfully busy. 所以这里周围很安静。 我还活着,非常。 只是非常忙。 保加利亚 (Bulgaria) I took a long trip in Bulgaria. About 1 month and 20 days. Including the traditional…

JavaScript控制输入框中只能输入中文、数字和英文

1、问题背景 遇到这样一个问题:有一个输入框,要求只能输入中文、数字和英文(即过滤特殊字符串) 2、JS代码 function checkUsername() { //正则表达式 var reg new RegExp("^[a-zA-Z\d\u4E00-\u9FA5]$"); //获取输入框…

简单分片逻辑

Sharding is the technique where you split static components across multiple domains so the browser can fetch more components in parallel? (Which browser? How many components per hostname? Ask browserscope.org) 分片技术是将静态组件拆分到多个域中&#xff…

JavaScript控制输入框只能输入非负正整数

1、问题背景 问题:一个输入框,输入的是月份,保证输入的内容只能是非负正整数 2、JavaScript代码 function checkMonth() { $("month").keyup(function(){ var temp $(this).val(); $(this).val(temp.replace(/ \ D/^0/g,)); })b…

org.hibernate.MappingException

1、错误描述 org.springframework.beans.factory.BeanCreationException:Error creating bean with name sessionFactory defined in ServletContext resource [/WEB-INF/applicationContext.xml]:Invocation of init method failed;nested exception is org.hibernate.Mappin…

E: 无法获得锁 /var/lib/apt/lists/lock - open (11: 资源暂时不可用)

1 错误描述 youhaidongyouhaidong:~$ sudo apt-get update E: 无法获得锁 /var/lib/apt/lists/lock - open (11: 资源暂时不可用) E: 无法对目录 /var/lib/apt/lists/ 加锁 2 错误原因 权限不够,导致出错 3 解决办法 youhaidongyouhaidong:~$sudo rm /var/lib/apt…

预加载,然后执行

I talked before about using an object element to load scripts and styles without executing/applying them to the current document. And this is nice for preloading assets - faster and less error-prone than simple inclusion if the document or iframe. 我之前讨…