Are you working on an Apache server? If so, you can just add this to your .htaccess file:
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{QUERY_STRING} fdl=1
RewriteRule .? - [T=application/octet-stream]
Checks to see it's a file Checks if parameter fdl=1 is in querystring Output as octet-stream/force download
Now when you want the browser to start downloading anything in that site, just put the parameter on the url:
Download Image
To do the same thing on a IIS windows server add the outbound rule to the web.config:
EDIT (10/4/2016):
Looks like the download
attribute is still not fully adopted by all the browsers.
For a JavaScript / browser based implementation you could look at FileSaver.js which is a polyfill for saving functionality in browsers that don't support it. It doesn't have perfect coverage though.