I am trying to download file using javascript window.open() on wordpress website. It works fine in all browser but in safari, tab stays open. It should close the tab automatically once file get downloaded. I am checking in safari version 13.1.
Here is the code I am using:
window.open('admin.php?action=downloadfile&name=53t52jd6772', "_blank");
In action=downloadfile I have written code to download file in php using php header(). I tried to close tab forcefully using window.close(); but in case when a confirm prompt appears to allow or cancel download then window.close(); closes the tab without allowing user to choose action.
Is that possible to automatically close browser after file download starts? I have been looking for the solution but didn't found any working solution.