The file name that the browser gives in the save dialog CAN be changed, but not in Javascript. Usually this is done when you don't give a direct link to an image, but use a PHP script such as < img src="image.php?id=18" >
To do this you just need to send proper http headers in image.php, for example:
header('Content-type: image/jpg');
header('Content-Disposition: inline; filename="' . $filename . '"');
If you use non-ASCII file name, you will need to encode it and unfortunately the encoding is different for different browsers:
- For IE use rawurlencode($filename)
- For FF use base64 with charset specification, such as '=?UTF-8?B?'.base64_encode($filename).'?='
If you specify "attachment" instead of "inline" in Content-Disposition header, the browser will not try to display the image but will immediately prompt user to download it.