Skip to content

Instantly share code, notes, and snippets.

@yannisxu
Created November 28, 2014 03:12
Show Gist options
  • Save yannisxu/8eabeb723f20a1633427 to your computer and use it in GitHub Desktop.
Save yannisxu/8eabeb723f20a1633427 to your computer and use it in GitHub Desktop.
js download file
var downloadURL = function downloadURL(url) {
var hiddenIFrameID = 'hiddenDownloader',
iframe = document.getElementById(hiddenIFrameID);
if (iframe === null) {
iframe = document.createElement('iframe');
iframe.id = hiddenIFrameID;
iframe.style.display = 'none';
document.body.appendChild(iframe);
}
iframe.src = url;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment