Forums

ForumsProgramming Forum

Website links

Posted Sep 18, '11 at 5:40pm

ExplosionsHurt

ExplosionsHurt

262 posts

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?

 

Posted Sep 29, '11 at 11:20am

jayjay9

jayjay9

499 posts

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

 

Posted Sep 29, '11 at 1:25pm

Darkroot

Darkroot

2,879 posts

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>

 
Reply to Website links

You must be logged in to post a reply!