Link to home
Start Free TrialLog in
Avatar of claghorn
claghorn

asked on

How do you make a webpage link persist.

I have a link on a web page:
<li><a href="news.aspx" >
                    News</a></li>
I use a css file to make it turn white on hovering but this effect dissapears after I click and move away.
#mainnav a:hover {
      color: #006699 ;
      text-decoration:none;
      background-color: #FFFFFF;
      }
How do I make the hover effect stick?
I could use onclick event maybe but how do I identify the link?
Avatar of abel
abel
Flag of Netherlands image

Do you mean that you want the link to show the same after you've clicked on it? You can use the :visited pseudo class for that
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of claghorn
claghorn

ASKER

Yes I want it to stay that way after clicking on it.
There is only 1 style sheet. Here is all the code for these links.
I just want to make the link stick (and only that link stick) for as long as the user is
on that page that they clicked the link for. I don't want their history showing by highlighting every
link they have clicked on. Nor do I wnt any link hihglighted when the page loads.
The links are in a master page that shows the links perpetually.

#mainnav a:link {
	color:#FFFFFF;
	text-decoration:none;
	
	}
 
#mainnav a:visited {
	color:#FFFFFF;
	text-decoration:none;
	
	}
 
 
#mainnav a:hover {
	color: #006699 ; 
	text-decoration:none;
	background-color: #FFFFFF;
 
	}
 
#mainnav a:active {
	
	color: #006699 ; 
	text-decoration:none;
	background-color: #FFFFFF;
	}

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This will keep only this link 'styled' this way. Make sure none of the other links are placed in the <span id="specialLink">.
I tried nmarun solution. Still it stays styled even after I click something else. It keeps history when I want it to forget history. Just style the page for which I clicked the link for. I think I need a java onclick event but do not know how to effect the link I clicked on.
OK, I am using the first solution offered. Works nice when visiting the page for first time. I'll compromise
on the memory of visted links staying in cache. But is there a way to default the visited (other than the main home visited) when I load the home page? I would default all the others to "not visited."

Don't worry too much on the memory. With or without your styles, it will reside in the memory and/or on disk. At some point (two weeks, sometimes longer / shorter, depending on settings) the links in memory will be removed and the link on your page will show the same as in the beginning.

That is standard behavior of browsers. If you want that different you'll have to keep track of visited links per user through a database, but there are very few sites that do that. Actually, users are used to this behavior and sometimes clear their cache by hand expecting everything to be back to original (which you can also do while testing).

If you have still questions, it is in general not a good idea to close the question and give a (lower) grade then you would've if all your questions are answered...