I am trying to save an image using Javascript on a button click in HTML using the following code:
function saveImage(anImage) {
if (typeof anImage== 'object')
Image= anImage.src;
window.win = open(anImage);
setTimeout('win.document.execCommand("SaveAs")', 500);
}
it works fine when I run the code from my local PC (ie it pops a new window and prompts me to save the image as a png file) , but when I deploy it to a server it pops the new window but it tries to save the page instead of the image (it opens a dialog box asking to save an htm file)
any reason ?
John Culviner wrote a jquery plugin that handles this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.