SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    "location = link.href;" not working

    Hi guys,

    I got this code inside a javascript function and it's not working. How to make it working?
    Code:
    go_here = document.getElementById("go_here");
    
    link = "welcome.php";
    
    function GoToTheLink() {
    	location = link.href;
    }
    
    go_here.addEventListener("click", function(event) {
    	GoToTheLink();
    });
    And the HTML code is:
    Code:
    <button id=go_here>Go Here</button>
    What I got is this:
    Code:
    http://localhost/project/home/undefined
    Thanks

  2. #2
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    325
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Never mind I got it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •