我已经<img>使用JavaScript 将源内容从html标记转换为base64String。图像显示清晰。现在,我想使用javascript将该图像保存到用户磁盘。<html> <head> <script> function saveImageAs () { var imgOrURL; embedImage.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA" + "AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO" + "9TXL0Y4OHwAAAABJRU5ErkJggg=="; imgOrURL = embedImage; if (typeof imgOrURL == 'object') imgOrURL = embedImage.src; window.win = open(imgOrURL); setTimeout('win.document.execCommand("SaveAs")', 0); } </script> </head> <body> <a href="#" ONCLICK="saveImageAs(); return false" >save image</a> <img id="embedImage" alt="Red dot"> </body></html>当我将图像路径设置为<img>html标签的源代码时,此代码运行良好。但是,当我将source传递为base64String时不起作用。如何实现我想要的?javascript HTML image base64
添加回答
举报
0/150
提交
取消