...

View Full Version : CSS link reset



cssdumb
07-15-2008, 09:10 PM
Hello,

I'd like to know how do I "reset" the links (colors) to the original setting every time a page is called.

So, as an example these are the initial conditions.

a:link {color: #0000C0;text-decoration: none;}
a:visited {color: #FF0000;}
a:hover { color:#FFFF3A; text-decoration : underline;}
a:active{color=#00C0C0;text-decoration : underline; }

Since a link has been visited it turns red.

Question is how do I reset the red link(s) o back to the initial conditions(#0000C0) ?

Thanks for any help

macwiz
07-15-2008, 09:52 PM
That cannot be done with HTML. You need a server side language that will log page calls and change the page details as the page is fetched.

ramm19
07-15-2008, 10:35 PM
Question is how do I reset the red link(s) o back to the initial conditions(#0000C0) ?

what if you simply do?


a:visited {color: #0000C0;}

bazz
07-16-2008, 01:14 AM
:eek::eek:


That cannot be done with HTML.
well thats correct but,


You need a server side language that will log page calls and change the page details as the page is fetched.

hmm, css isn't server side.

just make the 'visited' status show the color you want.



a:visited {
color:#0000C0;
}

oops, I didn't see ramm19's post
bazz

rafiki
07-16-2008, 01:16 AM
:eek::eek:

[quote=macwiz;712156]That cannot be done with HTML. [quote]
well thats correct but,



hmm, css isn't server side.

just make the 'visited' status show the color you want.



a:visited {
color:#0000C0;
}


bazz

Bazz didn't you see the reply above yours? It was already answered.
No harm in telling macwiz s/he was wrong though I suppose.

bazz
07-16-2008, 02:49 AM
I must have been adding the edit message when you posted because I realised it had been answered as soon as I saw mine posted.

Still, I have now edited it again, to fix the quotes tags.

bazz

macwiz
07-16-2008, 03:47 AM
I know that CSS isn't server side.

I am saying the you would need a Server Side Language to do it.

However, you may be able to do it with JavaScript and a cookie.

bazz
07-16-2008, 03:53 AM
but surely it just needs the one line of css. I don't think the OP is trying to reset computer/browser defaults: just the colour of the links in his/her own page

bazz

macwiz
07-16-2008, 03:57 AM
I'm just putting it out there as an option...

cssdumb
07-16-2008, 04:19 PM
That cannot be done with HTML. You need a server side language that will log page calls and change the page details as the page is fetched.


Thanks for the reply but
1. I just don't understand why di I need a server side language to reset the color.
2. I think there is a way to to do it though CSS but I don't no how.

cssdumb
07-16-2008, 04:43 PM
Thanks for the reply.

Problem is where should the a:visited{color:color:#0000C0;} be placed in the csstyle.css.

If I place it AFTER the one with #FF0000 the I get always a blue link and then I'm unable to tell which ones I've already visited (or anyone for that matter).

cssdumb
07-16-2008, 04:47 PM
but surely it just needs the one line of CSS. I don't think the OP is trying to reset computer/browser defaults: just the colour of the links in his/her own page

bazz

Yes, bazz. You're right. I just want to reset the color of the visited links in the page back to blue and not system wide (browser colors).

WyrmFyre
07-16-2008, 04:48 PM
LoVe HAte

LINK VISITED HOVER ACTIVE :D

Apostropartheid
07-16-2008, 04:52 PM
I'm confused, do you want visited links to be blue or visited links to be unvisited because you've been silly and started clicking them locally?

ramm19
07-16-2008, 05:17 PM
cssdumb, what you are asking is not possible with CSS alone, and it's not needed, your visitors won't really care if they see a different color or not for visited items until the refresh... simple use the same color for visited as for link and active. We all do it that way :)

macwiz
07-16-2008, 07:34 PM
This is why I said server side. The server can dynamically change the page. There is nothing locally that can replicate a user clearing their history before a refresh, which is what "cssdumb" seems to want to replicate.

bazz
07-16-2008, 08:40 PM
Well I am now totally confused as to what cssdumb wants to achieve.

@ cssdumb:
Normally links are set up so that when you have clicked on a link, the link changes to a different colour, so that the user knows they have already been there.

I think we need clarification as to what you want. Once a visitor has gone to a link, that link will always show the color as determined by the css - unless and until, they clear their browsing history.

So I think we need to know; are you trying to ensure that when people visit links in your site, that the links visited, show themsleves to be a color chosen by you OR, are you trying to make sure that each time they revisit your page, the visited links revert to non-visited/default.

If you want them to revert to default on subsequent page views, then make the visited colour the same as the non visited. If you want the visited links to change to a colour of your choice and to remain like this whenever they return, then use the answers you got early on the first page.


I don't understand why you would want to make your pages so that if I return to your site tomorrow that all the links are in their 'link' state rather than showing me which I had visited yesterday. I mean, if I didn't have time yesterday to see all your links, and I have returned today, it seems that you want me to start all over again because there wouldn't be a distinction between visited links and the others. That would make me leave your site never to return. The choice is and should be mine, as to whether I reset my browser to have clean links showing.

bazz

itsjareds
07-16-2008, 10:55 PM
If you want links to stay the same all the time, use the alink, vlink, and link <body> attributes.

Example:
<body link="#000000" alink="#000000" vlink="#000000">

That will keep your links black all the time.


If you want to make links refresh, just use some JavaScript:


<script type="text/javascript">
function refreshLinks()
{
var links = document.getElementsByTagName("a");
for (var a=0; a<links.length; a++)
{
links[a].style.color="#000000";
}
}
</script>

<a href="javascript:refreshLinks()">Click here to refresh your links!</a>

Apostropartheid
07-17-2008, 05:44 PM
No, don't use presentational attributes. The CSS syntax you have been using is both valid and more maintainable.

cssdumb
07-18-2008, 10:38 PM
Good idea. Thanks. I'll try it out. Probably will solve the issue. Will give you feedback.

cssdumb
07-18-2008, 10:41 PM
Thanks. Sorry messing up things with my dumb explanation. I'll try to avoid this situation in the future.

cssdumb
07-18-2008, 10:52 PM
I'm confused, do you want visited links to be blue or visited links to be unvisited because you've been silly and started clicking them locally?

Well, thanks for the reply but I'm confused now. i just don't understand what you are saying.

As I said earlier (in one of he replies) this page will run locally and not remotely.

About the links, please read the posting I used to start the discussion.

I guess using focus solves my problem partially but I've sen examples where guys reset everything, line p, li, td, prev :link, :visited, a, ..... etc. I just can't make it work.

Searched Google for reset links (before posting) and got some examples, but they don't seem to solve my question.

Thanks :)

Apostropartheid
07-18-2008, 11:00 PM
Sorry but it's just not possible unless you change the URLs of the hyperlinks to something else. Some user-agents reset them after a certain amount of time, but you just can't control it. I don't really see why you would want to do this, seeing as it defeats the point of visited links...

macwiz
07-18-2008, 11:32 PM
I think this is what you want, add it to your head:


<script type="text/javascript">
function refreshLinks()
{
var links = document.getElementsByTagName("a");
for (var a=0; a<links.length; a++)
{
links[a].style.color="#0000C0";
}
}
</script>

Change your body tag to this:
<body onload="refreshLinks();">

(Note this will only work if the viewer has JavaScript enabled.)

cssdumb
07-21-2008, 01:14 AM
Sorry but it's just not possible unless you change the URLs of the hyperlinks to something else. Some user-agents reset them after a certain amount of time, but you just can't control it. I don't really see why you would want to do this, seeing as it defeats the point of visited links...

OK. This is what happens when I visit, say 10 links in the page 01

1. Initial link 1=BLUE
2. Visited link 1RED
3 .Initial link 2 = BLUE
4. Visited link 2 = RED
.
.
.
down to link # 9 Link 10 WAS NOT visited this time.
5. I'm using FF 3.
6. I close FF using either X or "exit". 3 days later I call the page01 again.
7. I startup FF.
8. call the page 01
9. ALL visited links from earlier activity come up RED. Not good !
10. I don't care what I visited 3 days earlier.
11. What I want is a page01 with ALL links BLUE since I'm starting a new session and eventually, for this session, I'll need to know which ones I visited.
12. If every link from the 3-days-ago visit is RED THAT defeats the purpose of knowing which ones I visited in this particular session. (3 days after)

And no, I do not want to delete(clear) my FF buffer every time I have to access the page01, not today, not 10 days from today.


Is this example clear enough ?
I hope so.


Thanks for the reply.:)

cssdumb
07-21-2008, 01:16 AM
Thanks for the reply and I'll be testing this option tomorrow (0721/08) and will send you a feedback.

Would that work?

macwiz
07-21-2008, 01:21 AM
What are you testing? Your previous post is unclear...

cssdumb
07-21-2008, 03:21 PM
What are you testing? Your previous post is unclear...

Good question. Thanks for asking.

I have a PDF file that I changed to HTML format.
The PDF is a book and it has at least 32 chapters.

What I want is set a link from the index (32 of them) to match each corresponding chapter and allow the read links to be defaulted to "not read" when the user decides that there is no need to keep that chapter "flagged" as read.

Now, if a second user enter the same computer, he will find (if not reset) all links already read by someone else and that is not something I want to happen.
So turning each call to the HMTL back to the BLUE underlined default link would be the best choice. It would compartmentalize each user.
No need to show what one user (whoever it was) has read or not such and such chapter .

Unfortunately I cannot disclose the book name or it's contents.


I hope this helps understanding what I'm trying to achieve.
It might happen that my concept is not quite well developed at this point and other approach might be used to get what I want to do.

bazz
07-21-2008, 03:51 PM
My initial thought on that post is that you might want to look into some sort of login. Then the links might be able to be associated with the logged-in person so that any new loggerinner (:p) will have new unused links.

I haven't thought through how to do that 'association' but maybe someone else more knowledgable wil chip in here.

I reckon sessions and cookies might be the way though.

bazz

macwiz
07-21-2008, 04:36 PM
I think this is what you want, add it to your head:


<script type="text/javascript">
function refreshLinks()
{
var links = document.getElementsByTagName("a");
for (var a=0; a<links.length; a++)
{
links[a].style.color="#0000C0";
}
}
</script>

Change your body tag to this:
<body onload="refreshLinks();">

(Note this will only work if the viewer has JavaScript enabled.)


As I said, use this. It does exactly what you want.

Second, you are asking us to help you with something that can't be done how you want it done yet won't give us the resources (URL) of the issue so we can help more.

Third, its the WWW. NOTHING is private.

What bazz is saying requires setting up server side scripting, and unless you have a special need for it, is unnecessary. (no offense to bazz)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum