href image link download on click

I generate normal links like: <a href="https://stackoverflow.com/path/to/image"><img src="https://stackoverflow.com/path/to/image" /></a> in a web app.

When I click on the link, it displays the picture in a new page. If you want to save the picture, then you need to right click on it and select “save as”

I don’t want this behaviour, I would like to have a download box popping out when I click on the link, is that possible just with html or javascript? How?

If not I guess I would have to write a download.php script and call it into the href with the file name as parameter…?

10 Answers
10

Leave a Comment