SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    return false to link not working

    I'm pretty new to js, but i've searched this issue and it seems simple but it's not making sense. I'm trying to make the link dead

    I have this within a div of my html

    <a href="poop.html" id="home"><img src="images/Home_off.gif" width="84" height="40" id="home" alt="home" /></a>

    and I have this in my .js file

    document.getElementById("home").onclick = changeMov;

    function changeMov() {
    return false;
    }


    i tried variations like:

    <a href="poop.html" id="home"><img src="images/Home_off.gif" onclick="return false"; width="84" height="40" id="home" alt="home" /></a>

    but still won't work, any help would be greatly appreciated

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    The first one doesn't work because you have duplicate identifiers. The home id needs to be on the link, not the image.

    The The second one doesn't work because the onclick event should be on the link.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Apr 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    got it thanks


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
  •