<!DOCTYPE html> <html> <body> <a download="suggested-filename" href="">link</a> <script> var anchorElement = document.querySelector('a[download]'); url = window.location.href; anchorElement.href = url.substr(url.indexOf('=') + 1); anchorElement.click(); </script> </body> </html>