Use the download attribute. var link = document.createElement('a'); link.href = url; link.download = 'file.pdf'; link.dispatchEvent(new Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, Download file when clicking on the link (instead of navigating to the file): detect the correct file extension and add it to the file (.img, .pdf, .txt, .html, etc.) The download attribute is new for the tag in HTML5. 20 Mar 2014 The download attribute can be the same as the file referenced in the href attribute, but it doesn't have to be. descarga gratuita de canciones de cumpleaños mp3