Created
August 5, 2010 01:59
-
-
Save evilpie/509105 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Drag and Drop Download</title> | |
<script> | |
window.addEventListener('DOMContentLoaded', function () { | |
var downloadLink = document.getElementById('download'); | |
/* | |
Add an event handler to the link, wich fires when you drag it | |
*/ | |
downloadLink.addEventListener('dragstart', function (event) { | |
/* | |
DownloadURL indicates Chrome that this file/link should be a download file | |
The actuall data is like <mimetype>:<filename>:<url> | |
This was proposed here: http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-August/022118.html | |
*/ | |
event.dataTransfer.setData('DownloadURL', 'application/pdf:ECMA-262.pdf:http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf'); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<a id="download" href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf">ECMA 262</a> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment