ForumsProgramming ForumWebsite links

2 1871
ExplosionsHurt
offline
ExplosionsHurt
251 posts
Peasant

I've been working on a webpage and I've being trying to get a button to link to another website.

Eventually, I solved it by giving the button an id ("yellowButton&quot and referring to it in Javascript:

var button = document.getElementById("yellowButton"

yellowButton.addEventListener('click', gotoGamesPage, false);

function gotoGamesPage()
{
window.location = "http://www.explosionshurt.webs.com/games"
}


Doing it this way seems a bit primitive, because I'll have to do the above thing for every single button in the website. Is there any other, easier way to link a button to a different page?

  • 2 Replies
jayjay9
offline
jayjay9
497 posts
Shepherd

I think people, don't reply on this topic, cuz they don't understand what u mean. BTW, I don't understand it?

Darkroot
offline
Darkroot
2,775 posts
Shepherd

Felt primitive since you could do the same thing with a little html code?

<a href="http://www.explosionshurt.webs.com/games" class="yellowButton">Games</a>

Showing 1-2 of 2