Drag to Desktop in JS
In appmator, I wanted to avoid traditional web elements like 'Save As' buttons. Instead, I implemented a drag-to-desktop feature using Chrome's drag-and-drop functionality. By setting a 'DownloadURL' with a data URI or regular URL on the 'dragstart' event, users can drag data directly to their desktop. This method bypasses the need for a save button. The code example demonstrates how to use the dataTransfer.setData()
method with the DownloadURL
type. It leverages the JSZip
library to generate ZIP files as data URIs for dragging. This approach is Chrome-specific and has no feature detection available.