1

ie7&はデフォルトで base64 イメージ文字列をデコードできないためie8、別の方法を探していました。この問題についてグーグルで調べた後、 http://dean.edwards.name/weblog/2005/06/base64-ie/で良いチュートリアルを見つけました。

私が理解している限り、デコードのプロセスは次の2つの短いスクリプトで構成されています:

A. php base64 デコード関数

base64.php著者の指示に従って名付けられた

<?php
$data = split(";", $_SERVER["QUERY_STRING"]);
$type = $data[0];
$data = split(",", $data[1]);
header("Content-type: ".$type);
echo base64_decode($data[1]);
?>

B. JavaScript

base64.phpこれは、base64 画像文字列が埋め込まれ、最終的に処理とデコードのために画像文字列を渡すページの head タグ内に挿入されます。

<script type="text/javascript">
// a regular expression to test for Base64 data
var BASE64_DATA = /^data:.*;base64/i;
// path to the PHP module that will decode the encoded data
var base64Path = "base64.php";
function fixBase64(img) {
  // check the image source
  if (BASE64_DATA.png(img.src)) {
    // pass the data to the PHP routine
    img.src = base64Path + "?" + img.src.slice(5);
  }
};
// fix images on page load
onload = function() {
  for (var i = 0; i < document.images.length; i++) {
    fixBase64(document.images[i]);
  }
};
</script>

残念ながら、php base64 デコード関数は、私の場合、画像文字列をie7&ie8にデコードできません。

私のドキュメントタイプはDTD XHTML 1.0 Transitional&charset=utf-8です。

ここで何がうまくいかないのですか?

デモリンク:

base64-string-without-php-decoder: http://silentpond.eu5.org/base64-string-without-php-decoder.php

base64-string-with-php-decoder: http://silentpond.eu5.org/base64-string-with-php-decoder.php

ありがとう、

4

1 に答える 1

2

IE では、少なくともバージョン 8 以前で。URL の最大長は約 2047 バイトです。詳細については、http ://support.microsoft.com/kb/208427 を参照してください。

于 2013-03-27T19:11:36.077 に答える