Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    dep
    dep is offline
    Regular Coder
    Join Date
    Nov 2005
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing a link's destination via DOM....

    So I have this:

    <A HREF="javascript:dothis();" id="link">

    But, via DOM, I want to change the javascript to "javascript:dothat();"

    i thought it'd be something like:
    document.getElementById("link").nodeValue = 'javascript:dothat();'

    but alas, this does not work.

    any help?

    thanks,
    dep

  • #2
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Change your link to this:

    Code:
    <a href="#" id="link" onclick="doThis();return false;">Link</a>
    Then the JS:

    Code:
    document.getElementbyId('link').onclick=function(){doThat();return false;};
    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #3
    dep
    dep is offline
    Regular Coder
    Join Date
    Nov 2005
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Basscyst
    Change your link to this:

    Code:
    <a href="#" id="link" onclick="doThis();return false;">Link</a>
    Then the JS:

    Code:
    document.getElementbyId('link').onclick=function(){doThat();return false;};
    Basscyst
    Hey, that'll work. Thanks!


  •  

    Posting Permissions

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