Created
October 1, 2010 13:50
-
-
Save Munter/606239 to your computer and use it in GitHub Desktop.
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
// 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