Don't do it, not every browser will support it (opt-out for contextmenu events is also possible in some). Why should you want to do so?
I guess you want to link to the big versions of your thumbnails. So just put a link (<a>
) around your image tags and everyone will be happy. When you indicate the link with a descriptive tooltip, it would be even better.
EDIT:
When you have an image already included in a page, you can't change the default title the user agent will offer when you click [Save as]. Point, no exeptions.
The browser will likely use the file name from the download path. You can't change the src attribute dynamically (by script), because that would make another file load. What you can do is deliver the page with the files already under their aspired file names, but is to be done at the server.
So option #2 is starting a (new) file download. In the Content-Disposition
header you can dynamically (at the server) propose any filename for the sent content. For starting the download, just wrap your image into a link (of which you even can change the href attribute). Or you might want to build a custom context menu to display the download link as a [Save as] button (how to do so would be the matter of a different question).
Option #3 would be to open the file in a new tab/window, apply document.execCommand("SaveAs", [...])
on it and close the tab/window again. Unfortunately, this is only supported in Internet Explorer; see Does execCommand SaveAs work in Firefox? for this and the suggestions.