繁体   English   中英

在新选项卡上打开用 JS 创建的图像

[英]Open image created with JS on new tab

假设我有一个我之前使用 JS 创建的图像(例如画布的 base64),我想将它打开到一个新页面。我尝试了以下操作:

const src = "base 64 of the image";
window.open(src,'Image','width=largeImage.stylewidth,height=largeImage.style.height,resizable=1');

这现在正在工作(至少在最新的稳定 Chrome 版本上)..我错过了什么吗?

试试这个:

    var image = new Image();
    image.src = "data:image/jpg;base64, " + "base 64 of the image";

    var w = window.open("");
    w.document.write(image.outerHTML);
    w.document.close();

另外,请确保指定正确的内容类型,在我的回答中我使用的是 jpg

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM