I have logic, what when users clicks "download" button, it makes http request to rest api, and then by response browser or starts download, or writes user a message what download cannot be started, code looks like this
if (file.is_active) {
var link = document.createElement('a');
link.href = filesUri + file.path;
link.title = 'filedownload';
link.setAttribute('download', file.body);
link.click();
} else {
// error message
}
and this code works perfectly in safari/chrome, but it doesn't in firefox, is there any possibilities to bypass this check?
Firefox probably prevents downloading without user interaction.
You should put your button inside a tag, set listener to button and before event delegates to link change a attributes to download correct file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.