Web Analytics Made Easy -
StatCounter Change visited link color but back to default after refresh - CodingForum

Announcement

Collapse
No announcement yet.

Change visited link color but back to default after refresh

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Change visited link color but back to default after refresh

    Hi, I want to use a visited link color so people see what they've clicked on. Yet, from a designers perspective, I'd like to present a fresh array of unvisited links at the next visit.

    In order to achieve this I started with a Java Script which you can check out here. When you click on a link it changes color and it memorizes it until you refresh the page :-)

    PS: the challenge is also discussed in the PHP forum here.

    Now I want to control the unvisited and hover colors, as well as the "current page" color with CSS. However hovering only works when the link has not been clicked and it does not work at all on the currentpage link. Furthermore the currentpage link does not change color at all :-(

    I've tried a lot to find the solution but came to an end. I assume that the JavaScript has to be improved? Please help.

    Thank you,


    Martin

    Code:
    <script type="text/javascript" language="JavaScript"><!--
    	function changeColor(id) {
    		document.getElementById(id).style.color = 'green';	}
    //--></script>
    Code:
    <style type="text/css">
    
    	.navlink,
    	.navlink A:link,
    	.navlink A:visited { color: red; }
    
    	.navlink A:hover,
    	.navlink A:active { color: gray; }
    
    	#currentpage { color: black; }
    
    </style>
    Code:
    <DIV class="navlink"><a href="http://www.google.com" onclick="changeColor(1)" id="currentpage";><span id="1">Link1</span></a></DIV>
    
    <DIV class="navlink"><a href="http://www.ask.com" onclick="changeColor(2)";><span id="2">Link2</span></a></DIV>
    Last edited by mypointofview; Sep 23, 2006, 08:48 PM.

  • #2
    # 1.2) Do not crosspost- codingforum.net is divided into various categories. When initiating a thread, always locate the most appropriate category, and post your question only ONCE, in that category. Do not post the same question in multiple categories.

    http://www.codingforum.net/rules.htm
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

    Comment


    • #3
      Sorry for the crosspost.

      What if a subject concerns CSS, JavaScript and possibly PHP? Can JavaScript be discussed then also in the PHP section?

      If so, please delete or lock this thread. Thank you for telling me!


      Martin

      Comment


      • #4
        Originally posted by mypointofview View Post
        Sorry for the crosspost.

        What if a subject concerns CSS, JavaScript and possibly PHP? Can JavaScript be discussed then also in the PHP section?

        If so, please delete or lock this thread. Thank you for telling me!


        Martin
        yes, find the most relevant language and post the thread there.

        read the rules section, it is not long. and it spells this out for you.
        public string ConjunctionJunction(string words, string phrases, string clauses)
        {
        return (String)(words + phrases + clauses);
        }
        <--- Was I Helpfull? Let me know ---<

        Comment

        Working...
        X