1

我正在尝试IE6base64编码的字符串中渲染图像。根据此处此处的资源,我正在尝试以下代码(图像只是base64我的个人资料图片的编码在这里...... :),从这个网站获得)

<!--
Content-Type: multipart/related; boundary="=_data-uri"
-->
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
#pic {
width:670px;height:710px;
background-image: expression("url(mhtml:" + window.location + "!locoloco)");
}
</style>
<script type = 'text/javascript'>
window.onload = function() { alert(window.location); }
</script>
</head>
<body> 
<div>Foo</div>
<div id="pic" ></div>
<div id=test style="display: none;">

--=_data-uri
Content-Location:locoloco
Content-Transfer-Encoding:base64

/9j/4AAQSkZJRgABAgAAAQABAAD//gAEKgD/4gIcSUNDX1BST0ZJTEUAAQEAAAIMbGNtcwIQAABtbnRyUkdCIFhZWiAH3AABABkAAwApADlhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApkZXNjAAAA/AAAAF5jcHJ0AAABXAAAAAt3dHB0AAABaAAAABRia3B0AAABfAAAABRyWFlaAAABkAAAABRnWFlaAAABpAAAABRiWFlaAAABuAAAABRyVFJDAAABzAAAAEBnVFJDAAABzAAAAEBiVFJDAAABzAAAAEBkZXNjAAAAAAAAAANjMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXh0AAAAAEZCAABYWVogAAAAAAAA9tYAAQAAAADTLVhZWiAAAAAAAAADFgAAAzMAAAKkWFlaIAAAAAAAAG+iAAA49QAAA5BYWVogAAAAAAAAYpkAALeFAAAY2lhZWiAAAAAAAAAkoAAAD4QAALbPY3VydgAAAAAAAAAaAAAAywHJA2MFkghrC/YQPxVRGzQh8SmQMhg7kkYFUXdd7WtwegWJsZp8rGm/fdPD6TD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GosgnrTOUJ3AS3L3K8oNYfuaDXMIK0svwiqAqcEs9fnmo222RTTFyE8C+oPFtO4KsQbiCNGWOmCcwg5jvFRFICArUrVTRmdo3HGabOp/9k=
--=_data-uri--

</div>
</body>
</html>

但是当我在 中运行页面时IE6,图像没有显示出来。谁能告诉我我做错了什么,以及如何解决它以使其正常显示IE6?我将文件保存在我的桌面并尝试在IE6...中打开它

更新:

根据下面 Musa 的评论,我更改了代码以仅将 hack 包含在 CSS 中。还是行不通:

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
/*
Content-Type: multipart/related; boundary="=_data-uri"

--_
Content-Location:locoloco
Content-Type: image/png
Content-Transfer-Encoding:base64

/9j/4AAQSkZJRgABAgAAAQABAAD//gAEKgD/4gIcSUNDX1BST0ZJTEUAAQEAAAIMbGNtcwIQAABtbnRyUkdCIFhZWiAH3AABABkAAwApADlhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApkZXNjAAAA/AAAAF5jcHJ0AAABXAAAAAt3dHB0AAABaAAAABRia3B0AAABfAAAABRyWFlaAAABkAAAABRnWFlaAAABpAAAABRiWFlaAAABuAAAABRyVFJDAAABzAAAAEBnVFJDAAABzAAAAEBiVFJDAAABzAAAAEBkZXNjAAAAAAAAAANjMgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB0ZXh0AAAAAEZCAABYWVogAAAAAAAA9tYAAQAAAADTLVhZWiAAAAAAAAADFgAAAzMAAAKkWFlaIAAAAAAAAG+iAAA49QAAA5BYWVogAAAAAAAAYpkAALeFAAAY2lhZWiAAAAAAAAAkoAAAD4QAALbPY3VydgAAAAAAAAAaAAAAywHJA2MFkghrC/YQP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ZNtiVqHQlWQkGedS1NBVCj6QUcz3PhP4L4PLDG47TMfzfiCGosgnrTOUJ3AS3L3K8oNYfuaDXMIK0svwiqAqcEs9fnmo222RTTFyE8C+oPFtO4KsQbiCNGWOmCcwg5jvFRFICArUrVTRmdo3HGabOp/9k=

--=_data-uri--
*/
#pic {
width:670px;height:710px; *background: expression("url(mhtml:" + window.location + "!locoloco)");

}
</style>
<script type = 'text/javascript'>
window.onload = function() { alert(window.location); }
</script>
</head>
<body> 
<p>Foo</p>
    <div id="pic" ></div>
</body>
</html>
4

2 回答 2

1

您的代码中有错误的资源分隔符:

Content-Type: multipart/related; boundary="=_data-uri"

=_data-uri是一个分隔符,您必须使用它来分隔图像。

例如:

/*
Content-Type: multipart/related; boundary="_"

--_
Content-Location:locoloco
Content-Type: image/png
Content-Transfer-Encoding:base64

iV... // image here
--_
Content-Location:locoloco2
Content-Type: image/png
Content-Transfer-Encoding:base64

iV... // image here
*/

最后一张图片的末尾不需要分隔符。

在您的代码中,您已经声明了 separator ,在第一个图像之前=_data-uri使用 separator并在它之后使用。_=_data-uri--

为了使它工作,将第一个更改为声明的一个,最后删除一个。

这段代码对我有用(也在mhtml中写了固定的url,一定要把它改成适合你的):

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
/*
Content-Type: multipart/related; boundary="_"

--_
Content-Location:locoloco
Content-Type: image/png
Content-Transfer-Encoding:base64

/9j/4AAQSkZJRgABAgAAAQABAAD//gAEKgD/4gIcSUNDX1BST0ZJTEUAAQEAAAIMbGNtcwIQAABtbnRyUkdCIFhZWiAH3AABABkAAwApADlhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApkZXNjAAAA/AAAAF5jcHJ0AAABXAAAAAt3dHB0AAABaAAAABRia3B0AAABfAAAABRyWFlaAAABkAAAABRnWFlaAAABpAA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kL6zDiwkV8G4/yZgZU64P8BBuhqUKgHARYBZheIFghMQg0t26PEY8G5esRKWNrmriq5hHYg9zu2Ze6L0QO52kIHmXPqCP3EqljxWzAsefM3eszACnKH6TGyNmv6CBrbMrFncxjLkfS9SpMtMVhDRjD3lVqriOAeZSOVRyAOOIV+jKOZUYZc2vMZGpm/gVbZgHLBA8S8eGODQlvz5lhhAYhN0uXOGUx6Gz/ACXKx9wgtwOmBdfmA6mCMlRcZlBMUoNxR6gYeiO/MwlYAXLwZtfmNoWoYJicqTnpMTRANPP6hsAjHNMfqleTSXO13GxFixDsGHcfbEBnL3MkcoVmyJk1dSqKy2zGRW8wDVCiD6wOh9LDdvULgWaCCnB04j1YW4ZNtiVqHQlWQkGedS1NBVCj6QUcz3PhP4L4PLDG47TMfzfiCGosgnrTOUJ3AS3L3K8oNYfuaDXMIK0svwiqAqcEs9fnmo222RTTFyE8C+oPFtO4KsQbiCNGWOmCcwg5jvFRFICArUrVTRmdo3HGabOp/9k=
*/

#pic {
    width:670px;
    height:710px;
    *background: expression("url(mhtml:http://localhost/~iadramelk/tmp/base64.html!locoloco)");

}
</style>
</head>
<body> 
<p>Foo</p>
<div id="pic" ></div>
</body>
</html>
于 2013-02-18T12:33:08.057 回答
0

base64 图像出现在 IE6 和 IE7 中……最后,当您在 css 中使用编码图像时,我找到了一个简单的解决方案。

“在同一个类中写两个不同的属性”

我将在下面解释它。

<div class="myClass">    </div>
<style>
    .myClass {
            /*this will work for other browsers*/
            background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAHCAYAAADam2dgAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAySURBVHjaYlSdd/4/AwQwQml0PgMTHsn/yIoYCCmEKcKrEFkRTrcxEVIAs46g7wACDACraA+g90OOjwAAAABJRU5ErkJggg%3D%3D');        
            /* For ie6 and ie7*/
            *background:url('give real path_to_image');
    }
</style>
于 2013-04-15T16:00:10.563 回答