Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving images using JS

 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a page that displays a list of images, under each image is a link. When you click on this link I want the IE "Save File" dialog to popup asking the user to save the image to their machine.
I've managed to get this bit to work but I can not get it to save the image, instead if tries to save the actual HTML of the page.
My script code is as follows:
function downloadImage(pid)
{
document.execCommand("SaveAs",null, IMAGE_NAME);
}
<a href="javascript ownloadImage('<%=pid%>')">Save Image</a>
Any help would be appreciated
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As this has nothing to do with JSP, I'm moving it along to the HTML/Javascript forum.
bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic