wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Saving images using JS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Saving images using JS" Watch "Saving images using JS" New topic
Author

Saving images using JS

Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
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


Cheers!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60755
    
  65

As this has nothing to do with JSP, I'm moving it along to the HTML/Javascript forum.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving images using JS
 
Similar Threads
can server send picture in 'ajax' interaction
How insert image to primefaces commandbutton?
StringBuffer
html:link wraps a button but not on IE
How img link is working ?