Created
May 6, 2012 16:55
-
-
Save rudiedirkx/2623261 to your computer and use it in GitHub Desktop.
Download any File/Blob via JS
This file contains hidden or 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
/** | |
* `url` can be a data URI like data: or a blob URI like blob: or an existing, public resource like http: | |
* `filename` is the (default) name the file will be downloaded as | |
*/ | |
function download( url, filename ) { | |
var link = document.createElement('a'); | |
link.setAttribute('href',url); | |
link.setAttribute('download',filename); | |
var event = document.createEvent('MouseEvents'); | |
event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); | |
link.dispatchEvent(event); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
doen't work for outube