SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot dustbuster's Avatar
    Join Date
    Jan 2003
    Location
    End-World
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change text in link

    This probably has been covered already but I'm having trouble finding it.

    I want to be able to change the text in a link if someone mouses over it or clicks it.

    Ex:
    I have a link 'Out'.
    When a visitor mouses over it changes to 'Over'.
    When they click it changes to 'Click'.


    Can anyone help?
    I need it to work in NS 6 + and IE 5.5+

    Thanks
    D.

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <a href="#" onmouseover="this.innerHTML='Over';" onmouseout="this.innerHTML='Out';" >Link</a>

  3. #3
    SitePoint Zealot dustbuster's Avatar
    Join Date
    Jan 2003
    Location
    End-World
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! That seems to be buggy in NS though. It displays 'Link' when the page first loads. It changes to 'Over' when I mouse over. But when I mouse out it stays at over.

    Any ideas?

  4. #4
    SitePoint Zealot Saj's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which version os NS? 6 and 7 should work fine, but if its 4, then don't worry too much about that. Most people have stopped coding especially for NS4

  5. #5
    SitePoint Zealot dustbuster's Avatar
    Join Date
    Jan 2003
    Location
    End-World
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm using NS 7

  6. #6
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Same problem here, when I tested in NS7

  7. #7
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <html>
    <head>
    <script type="text/javascript">

    function setTextNode(obj, text) {
    if (obj.lastChild.nodeType == 3)
    obj.lastChild.nodeValue = text;
    }

    </script>
    </head>
    <body>
    <a href="#"
    onmouseover="setTextNode(this,'Over')"
    onmouseout="setTextNode(this,'Out')"
    onclick="setTextNode(this,'Click')">Link</a>
    </body>
    </html>
    Last edited by adios; May 29, 2003 at 18:13.

  8. #8
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works in NS7

  9. #9
    SitePoint Zealot dustbuster's Avatar
    Join Date
    Jan 2003
    Location
    End-World
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That works! 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
  •