Asi*_*sif 3 javascript browser jquery base64 image
我有 Base64 编码图像作为响应,如何使用 js 在浏览器的新选项卡中显示该图像?任何人都可以提出解决方案。谢谢
success: function (base64Image) {
}
Run Code Online (Sandbox Code Playgroud)
假设你要得到一张 GIF 图像:
// Display a base64 URL inside an iframe in another window.
function debugBase64(base64URL){
var win = window.open();
win.document.write('<iframe src="' + base64URL + '" frameborder="0" style="border:0; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%;" allowfullscreen></iframe>');
}
success: function (base64Image) {
// e.g This will open an image in a new window
debugBase64("data:image/gif;base64," + base64Image);
// you can try with this base64 (it is a red dot)
// debugBase64("data:image/gif;base64,R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=");
}
Run Code Online (Sandbox Code Playgroud)
否则只需更改data:image/gif;为您需要的正确 MIME 类型即可。
您可以在此处找到完整列表https://www.freeformatter.com/mime-types-list.html