I need to have a page that accesses two links, one in a window/tab that downloads a file and another one that after about 5 seconds or so accesses directly to this linl.
Currently I have the following code:
if ("URL1" !== '') {
const link = document.createElement('a')
link.href = "URL1"
link.target = "_blank"
link.download = "pdf"
link.click()
setTimeout(function() {window.location.href = "URL2"; }, 5000 );
} else {
window.location.href = "URL2" />"
}
I've tried to force the download in several ways with Javascript since the tool I work with doesn't allow PHP, but I can't get it to download correctly.