Ryan Seddon, aka the CSS Ninja, has a nice blog post up where he reverse engineers the new feature in Gmail where you can drag attachments from an email on to your desktop. Note that the feature only currently works in Chrome.
Ryan begins with the following code:
JAVASCRIPT:
Describing the code Ryan says: From the code above you attach an ondragstart event listener to something you want to “drag out” and save to your file system. On the dragstart event you set the data using the new “DownloadURL” type and pass file information to it.
Note though that in order to pass the correct data to the dragstart event you need to provide a download URL that can be passed to the setData("DownloadURL" call.
Read more: ajaxian
Ryan begins with the following code:
JAVASCRIPT:
var file = document.getElementById( "dragout" );
file.addEventListener( "dragstart", function( evt ) {
evt.dataTransfer.setData( "DownloadURL", fileDetails );
}, false);
Describing the code Ryan says: From the code above you attach an ondragstart event listener to something you want to “drag out” and save to your file system. On the dragstart event you set the data using the new “DownloadURL” type and pass file information to it.
Note though that in order to pass the correct data to the dragstart event you need to provide a download URL that can be passed to the setData("DownloadURL" call.
Read more: ajaxian