From d0d408230a1cd38edcd62fdaa7a6cd5ea026240b Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Mon, 10 Jun 2024 21:08:44 -0400 Subject: [PATCH] Adding buttons instead of links for downloads --- app.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index d4c06a8..db71833 100644 --- a/app.js +++ b/app.js @@ -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);