[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do you make a webpage link persist.

Posted on 2009-02-22
8
Medium Priority
?
277 Views
Last Modified: 2012-06-27
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?
0
Comment
Question by:claghorn
  • 3
  • 3
  • 2
8 Comments
 
LVL 39

Expert Comment

by:abel
ID: 23705721
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
0
 
LVL 39

Accepted Solution

by:
abel earned 90 total points
ID: 23705729
I haven't seen your whole CSS, but if there are no conflicting stylesheets, you can so something like this:

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

Open in new window

0
 

Author Comment

by:claghorn
ID: 23705810
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

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Assisted Solution

by:nmarun
nmarun earned 60 total points
ID: 23705870
Try this:

<span id="specialLink"><a href="http://www.cnn.com/" >cnn</a></span>

Change your stylesheet to:
#specialLink a:visited,
#specialLink a:hover
 {
      color: #006699 ;
      text-decoration:none;
      background-color: #FFFFFF;
}
0
 
LVL 27

Expert Comment

by:nmarun
ID: 23705878
This will keep only this link 'styled' this way. Make sure none of the other links are placed in the <span id="specialLink">.
0
 

Author Comment

by:claghorn
ID: 23705993
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.
0
 

Author Comment

by:claghorn
ID: 23706047
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."

0
 
LVL 39

Expert Comment

by:abel
ID: 23709270
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...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question