4

My site uses data uri:s to reduce the number of HTTP requests to my site. The problem is that data uri:s don't work in IE7, a browser that we have to support (No, we don't need IE6). I've followed Stoyan's guide and actually gotten it to work, but after a recent Microsoft security update (KB2544893, as descibed in a comment on the original article) the fallback seems to have stopped working.

The comment referenced above suggests I should try sending the MSHTML file with Content-Type message/rfc822, but I can't get this to work either, and I've tried multiple different ways over a course of several hours.

So my question is this: Can you get the technique described by Stoyan to work somehow? I would really appreciate a working example to convince me that it truly is possible.

4

3 に答える 3

3

私はStoyanStefanov(テクニックの元の作者)と連絡を取り、彼は彼の元の例を修正して、現在は機能するようにしました。必要なのは、コンテンツタイプとして「message/rfc822」を追加するだけでした。

修正例:http ://www.phpied.com/files/datasprites/testhover2.html

ポイントを獲得できるように、ここにコメントを投稿するように頼みましたが、彼は望んでいませんでした。

于 2011-10-02T09:57:38.823 に答える
3

個人的には、条件付きスタイルを使用します。メインのマークアップで、次のように開始します。

<!DOCTYPE html>
<!--[if IE 7]>    <html lang="en-us" class="ie7"> <![endif]-->
<!--[if IE 8]>    <html lang="en-us" class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en-us"> <!--<![endif]-->

CSS で次のことができるようになりました。

.myClass {
      background-image: url(/*DATAURI GOES HERE*/);
}

.ie7 .myClass {
      background-image: url(fallback-image.png);
}

アップデート

以下のコメントに加えて、IE7 のパフォーマンスが気になる場合は、IE7のフォールバック イメージをスプライトにするのが確実な方法です。

そうすれば、IE7 ユーザーに対して追加の HTTP 呼び出しを 1 つだけ行うことができます。

.ie7 .myClass {
      background-image: url(fallback-sprite.png);
      background-position: 150px 15px;
}
于 2011-09-20T07:01:53.557 に答える
0

http://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/ここに私が思うあなたの解決策があります

于 2011-09-27T04:35:56.520 に答える