I have an Electron application that opens an external page. Inside this page, I have a button to download a file. On a normal browser, when I click the download button, it opens a _blank tab and start the download automatically, and immediately closes the tab. But, on Electron application, the _blank tab opens a new Window and ask for download location and the window don't close automatically, as desired.
How can I reproduce the "normal" browser behaviour on Electron?
The code to download the file is:
window.open(url, '_blank', '');
Thank you
What if you replace your code to download the file with a dummy link element:
var a = document.createElement("a");
a.href = url;
a.download = "filename";
a.click();
Does that result in the same behavior or could it be an acceptable workaround?
EDIT: Or perhaps even simpler; replace your download button with a link (that you can style as a button):
<a href="your-data-uri" download="filename">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With