Skip to content

Instantly share code, notes, and snippets.

@Munter
Created October 1, 2010 13:50
Show Gist options
  • Save Munter/606239 to your computer and use it in GitHub Desktop.
Save Munter/606239 to your computer and use it in GitHub Desktop.
// This should enable drag/dropping of file links from a webpage to desktop in browsers with support (Chrome)
window.onload = function() {
var as = document.getElementsByTagName('a');
for (var i = 0; i < as.length; i++) {
as[i].addEventListener('dragstart', function(link) {
return function (evt) {
evt.dataTransfer.setData('DownloadURL', 'application/octet-stream:' + link.href.replace(/^.*\//, '') + ':' + link.href);
};
}(as[i]), false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment