the goal of my code is to generate a new link each time "generate" is pressed, so that i can find new songs for geometry dash without having to spam numbers.
i have tried the string below but every time the button were to be clicked, it would append a new set of numbers on the end. i wish for the program to not require a refresh
document.querySelectorAll("a").forEach(link =>
link.setAttribute("href", link.getAttribute("href") + Math.floor(Math.random() * 111392.8) + 1)
this is my current attempt. i have gotten the goal of a new number on every button press with a refresh but the prefix of "https://www.newgrounds.com/audio/listen/" won't append to the start.
window.onclick = () => {
document.querySelectorAll("a").forEach(link =>
link.setAttribute("href", Math.floor(Math.random() * 111392.8) + 1)
);
};
<title>
Newgrounds Song Generator
</title>
<body>
<h1>Click the button to visit a random song!</h1>
<a href="https://www.newgrounds.com/audio/listen/" target="_blank">
<button>Generate</button>
</a>