Trying to make it download

I’m trying to make clicking on the link make it download. It only refreshes the page right now.

<h1 id="MainText"></h1>
<h2 id="MainText2" ></h2>
<body>
    <a download="WhySweden" href="C:\Users\capta\Downloads\The_Rake_Files\New folder\WhySweden.html"> download the files here</a>
</body>
<p id ="ColouredText" style="color:red; font-family: sans-serif;"> 

<a download="WhySweden" href="C:\Users\capta\Downloads\The_Rake_Files\New folder\WhySweden.html"> download the files here</a>

<script>
const theHeader = document.getElementById("MainText")
const ColouredText = document.getElementById("ColouredText")
const RandomNum = Math.random()
console.log(RandomNum)
theHeader.textContent = "Random number of the day: " + RandomNum
ColouredText.textContent = "wow"
</script>

I am afraid you have to move all the HTML Tags into the section of “<“body”>” “<”/body">". Otherwise, the page would not work properly.

Actually, the “it just refreshes the page” part was false, I was opening it as a file.

Still doesn’t work. At all.

<body>
    <a download="WhySweden" href="C:\Users\capta\Downloads\The_Rake_Files\New folder\WhySweden.html"> download the files here</a>
</body>

Can you post the entire part of your html file, please?

That’s the entirety of my HTML file.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.