在image标记中,当在image src属性上设置base64时,浏览器崩溃, -操作系统:-32位窗口。 -版本:-6.1(Windows 7,Windows Server 2008 R2) -Chrome版本:-73.0.3683.103
var bytImageData = File.ReadAllBytes(fileWithPath + ".png");
string strBase64ImageData = Convert.ToBase64String(bytImageData, 0, bytImageData.Length);
File.WriteAllText(fileWithPath + ".txt", strBase64ImageData);
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
load();
});
var _imageByteStream;
function load() {
$("#scream").attr("src", "");
$("#performanceText").val($("#performanceText").val() + '\n' + "Before image load :" + window.performance.memory.usedJSHeapSize);
$.ajax({
url: "Content/Images/ImageStream" + $("#imageSize").val().replace('MB', '') + ".txt",
dataType: "TEXT",
contentType: 'application/json',
async: false,
success: function (response) {
_imageByteStream = response;
}
});
$("#scream").attr("src", "data:image/png;base64," + _imageByteStream);
$("#performanceText").val($("#performanceText").val() + '\n' + "After image load :" + window.performance.memory.usedJSHeapSize);
_imageByteStream = null;
}
</script>
</head>
<body>
<div>
<table>
<tr>
<td>
<div style="width:400px;height:300px;"><img id="scream" alt="The Scream" width="400" height="300" /></div>
</td>
<td>
<div style="width:400px;height:300px;">
<textarea style="width:280px;height:300px;" id="performanceText"></textarea>
</div>
</td>
</tr>
<tr>
<td>
<select style="margin-top:10px;" id="imageSize">
<option>50MB</option>
<option>57MB</option>
</select>
</td>
</tr>
<tr>
<td><button style="margin-top:10px;" onclick="load()">Load</button></td>
</tr>
</table>
</div>
</body>
</html>