AshleyScirra
2016-05-11
It looks like browsers are moving away from allowing JS-dispatched events from performing their default actions. (e.g.: crbug.com/520519)
AFAIK the only way to invoke a download from JS is the following steps:
- Create a temporary
<a>
and attach it to the document - Set the “href” and “download” attributes
- Dispatch a synthetic “click” event at it
- Remove the temporary
<a>
Perhaps there should be a navigator.download(url, 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!