Adding buttons instead of links for downloads

This commit is contained in:
Raven Scott 2024-06-10 21:08:44 -04:00
parent 3dcabac0b4
commit d0d408230a

14
app.js
View File

@ -456,11 +456,15 @@ function addFileMessage(from, fileName, fileUrl, fileType, avatar) {
$image.classList.add('attached-image');
$content.appendChild($image);
} else {
const $fileLink = document.createElement('a');
$fileLink.href = fileUrl;
$fileLink.textContent = `File: ${fileName}`;
$fileLink.download = fileName;
$content.appendChild($fileLink);
const $fileButton = document.createElement('button');
$fileButton.textContent = `Download File: ${fileName}`;
$fileButton.onclick = function() {
const $fileLink = document.createElement('a');
$fileLink.href = fileUrl;
$fileLink.download = fileName;
$fileLink.click();
};
$content.appendChild($fileButton);
}
$div.appendChild($content);