Re: [request] "Download" Event for HTMLAnchorElement

On 3/24/14 1:16 PM, "Glenn Maynard" <<>> wrote:
On Mon, Mar 24, 2014 at 2:45 PM, Si Robertson <<>> wrote:
The web browser will definitely know when the data has been written to disk, the problem is the developer won't know when the data has been written to disk, so it's currently impossible to revoke the object URL (release the data from memory) at a safe time. When the anchor is clicked you could create a timer and revoke the object URL after a certain number of seconds have elapsed but you will still be taking a shot in dark.

If you don't care about the user clicking the link more than once, it should always be safe to release the object URL immediately after the click event has completed.  If the browser has begun downloading (copying to disk) the blob, that operation should be unaffected by you releasing the object URL.  You would just need to use a zero-second timer, so that you release it after the click event has completed and not while it's being dispatched.

(If you do something like this, be sure to hide the download link and at least replace it with a "Download in progress", or better a "Click here to restart download" to regenerate the blob, so you don't leave a broken anchor on the page.)

This may not  work in browsers yet, and this may not be well-defined in the spec.  If it's not, I'm guessing it'll be fixed as part of

But I do care about the user clicking more than once. I know I do that occasionally, and would be annoyed at a site that wouldn't let me, and I don't want to annoy my users in that way. Presumably in that case I want the URL and blob to stay around until the page goes away, which I'd guess is how it would work?


Received on Monday, 24 March 2014 22:25:21 UTC