Invoke download without dispatching event

It looks like browsers are moving away from allowing JS-dispatched events from performing their default actions. (e.g.:

AFAIK the only way to invoke a download from JS is the following steps:

  1. Create a temporary <a> and attach it to the document
  2. Set the “href” and “download” attributes
  3. Dispatch a synthetic “click” event at it
  4. Remove the temporary <a>

Perhaps there should be a, filename) method or similar to do the same thing but without having to rely on synthetic events? It would also be a much nicer API than muddling with temporary elements!

1 Like

Actually I was just informed that can work instead of dispatching an event. But maybe there should be a nicer API for this anyway?

1 Like