dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Creating a visited link in the nav section of a one page site

  1. #1
    Join Date
    Jan 2010
    Posts
    8

    Creating a visited link in the nav section of a one page site

    Anyone know how I can change the color of a text link on a page that doesn't load a new page, but rather stays on the same page?

    The nav links already use an onClick to present content below it that changes depending on what link in the nav I select. In other words, there's already two things going on -- links take you to content on the same page using a JS onClick.

    What I want to add to that is when you click on the link, it changes style, like turns bold or changes color. So then the user knows that not only have they selected new content, but the link they selected stands out as well.

    Thank you,
    S

  2. #2
    Join Date
    Nov 2006
    Location
    Oakland
    Posts
    500
    You could give each one of those links an ID then include the id value as a parameter of the click handler. For instance:
    <a href="#here" onclick="ShowSection('section1", 'link1') id="link1">Anchor Text</a>

    In your JavaScript function:

    function Showsection(pagesection, clickedlink){
    /*
    whatever the function does to the page content
    */
    document.getElementById(clickedlink).style.color="#FF0000";
    }

    Of course if there is a unique correspondence between the "pagesection" parameter and the clicked link then only one parameter should suffice. You can extract the link ID knowing what section is called to be displayed. Otherwise the logic shown above is a simplistic way of getting the results you are seeking.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles