Erisa/download-image

Legacy Edge support

Closed this issue · 1 comments

Erisa commented

Despite the ongoing switch to Chromium-based Edge, for the time being it may be worth looking into support for UWP Edge. This shouldn't be too difficult, the only block at the moment is that the download API isn't supported. This could potentially be worked around by abusing data: URIs to force a download.

Erisa commented

I tried doing this through a couple methods, but can't get it to work.
To detect Edge, I used

var isIE = /*@cc_on!@*/false || !!document.documentMode;
var isEdge = !isIE && !!window.StyleMedia;

Then, I first looked into the idea of abusing data: URIs, but considered it to be impractical (May look into further in future).
Secondly I looked into the idea of creating a link DOM object and clicking it through JavaScript, It looked like the following:

var link = document.createElement("a");
link.download = true;
link.href = info.srcUrl;
link.click();

But for whatever reason, this crashes the browser.
You can also execute this code on the tab, but that won't work for images which are hosted on other domains to the currently viewed page.