Last active
September 1, 2016 10:07
-
-
Save lincerely/b7be27aea493f966d33f7332604bf9e8 to your computer and use it in GitHub Desktop.
download file from link with "a" 's download tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<meta charset="UTF-8"> | |
<title>Download from link</title> | |
</head> | |
<body> | |
<h1>Please use Chrome or Opera</h1> | |
<h2>cross origin download is not allow in Firefox,<br> so it will open the file in your broswer.</h2> | |
<input id="link" type="text" /> | |
<a id="button" download>Download</a> | |
<script> | |
var link = document.getElementById('link'); | |
var button = document.getElementById('button'); | |
link.onchange = function(){ | |
button.href = link.value; | |
console.log('link changes to '+link.value); | |
} | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment