473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Change text color of "visited link" back to unvisited color ???

As well known I could specify the text color in the body tag like:

<BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE>

What I want to achieve now is that always (!) the text of the last visited link and
the text of the link under the cursor are red. All other links should be white.

The problem with the construction above is that a visited link remains for the rest of
the session red regardless wether it was visited 17 clicks back in the history or even just before.

I wanted ONLY the LAST visited link in red and - additionally -
the current link under the cursor (while the user chooses another link).

Probably I need a Javascript function.

Could someone help me ?

cu
Matt

Jul 20 '05 #1
9 52294
Matt Adams wrote:
As well known I could specify the text color in the body tag like:

<BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE>

What I want to achieve now is that always (!) the text of the last
visited link and
the text of the link under the cursor are red. All other links should
be white.


use CSS to do this..

a {color:#fff;}
a:visited {color:#fff;}
a:active, a:hover {color:#f00;}

teh ":active" thing tells the browser to apply this style when the focus is
on the link. I think this is about as far as css will be able to help you
out.
Jul 20 '05 #2
Ma********@email.com (Matt Adams) writes:
As well known I could specify the text color in the body tag like:

<BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE>
As also well known, you should't, and should instead use CSS:

<style type="text/css">
body {color:white;}
:link {color:white;}
:visited {color:red;}
:visited:active {color:white}
</style>
What I want to achieve now is that always (!) the text of the last
visited link and the text of the link under the cursor are red. All
other links should be white.
The one under the cursor can be done in CSS too:

<style type="text/css">
body {color:white;}
:link, :visited {color:white;}
:link:hover, :visited:hover {color:red;}
</style>

(or, if by "the one under the cursor" you mean the one you are pressing,
not just the one you are hoovering above, then change ":hover" to ":active").

The problem is to color only one of the previously used links.
The problem with the construction above is that a visited link
remains for the rest of the session red regardless wether it was
visited 17 clicks back in the history or even just before.

I wanted ONLY the LAST visited link in red and - additionally -
the current link under the cursor (while the user chooses another link).

Probably I need a Javascript function.


You do.
I assume that your links have a target attribute, so the page itself isn't
changed (otherwise it makes no sense :).

Try this script:
---
<script type="text/javascript">
var lastClickedLink = null;
function rememberLink() {
if (lastClickedLink) {lastClickedLink.style.color = "";}
lastClickedLink = this;
this.style.color = "red";
}
function makeMemory() {
for (var i=0; i<document.links.length; i++) {
var link = document.links[i];
if (link.addEventListener) {
link.addEventListener("click",rememberLink,false);
} else if (link.attachEvent) {
link.attachEvent("onclick",rememberLink);
} else {
link.onclick=rememberLink;
}
}
}
<script>
---
It adds an onclick event handler to all links on the page,
and when one is clicked, it changes the color of the previous one
to default, remembers the currently clicked link, and makes it red.

You call the function from, e.g., the body onload event, so it is
called when all links have been loaded.
---
<body onload="makeMemory()">
---

Good luck.

Followup-To set to comp.lang.javascript.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
rf

"Matt Adams" <Ma********@email.com> wrote in message
news:bi*************@news.t-online.com...
As well known I could specify the text color in the body tag like:

<BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE>
Hmmm. It is well known these days that such presentational things are done
with CSS.
What I want to achieve now is that always (!) the text of the last visited link and the text of the link under the cursor are red. All other links should be white.
The problem with the construction above is that a visited link remains for the rest of the session red regardless
Nope. See below.
wether it was visited 17 clicks back in the history or even just before.

I wanted ONLY the LAST visited link in red and - additionally -
the current link under the cursor (while the user chooses another link).

Probably I need a Javascript function.


No. You need to rethink that you want.

The 'visited' colour is there so your viewer can see that she has been to
that particular page before. Nothing more. nothing less.

'Visited' links get 'unvisited' when your viewers history gets emptied or
expires, something over which you have no control whatsoever.

You could fudge it by looking at the referring page and colouring it's link
on the new page but would be a whole bunch of server side stuff for IMHO
little gain.

Why do you want to do this anyway?

Cheers
Richard.
Jul 20 '05 #4

"Matt Adams" <Ma********@email.com> wrote in message
news:bi*************@news.t-online.com...
As well known I could specify the text color in the body tag like:

<BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE>

What I want to achieve now is that always (!) the text of the last visited link and the text of the link under the cursor are red. All other links should be white.
The problem with the construction above is that a visited link remains for the rest of the session red regardless wether it was visited 17 clicks back in the history or even just before.
I wanted ONLY the LAST visited link in red and - additionally -
the current link under the cursor (while the user chooses another link).

Probably I need a Javascript function.

Could someone help me ?


This is a browser function. There is no way of differenciating between a
link visited a moment ago and one 20 minute ago.A VLINK is a VLINK.
Jul 20 '05 #5
Matt Adams wrote:
What I want to achieve now is that always (!) the text of the last visited link and
the text of the link under the cursor are red. All other links should be white.


Cannot be done.

--
Toby A Inkster BSc (Hons) ARCS | mailto:to*****@goddamn.co.uk | pgp:0x6A2A7D39
aim:inka80 | icq:6622880 | yahoo:tobyink | jabber:ta*@jabber.linux.it
http://www.goddamn.co.uk/tobyink/ | "You've got spam!"
playing://(nothing)
Jul 20 '05 #6
In article <bi*************@news.t-online.com> in
comp.infosystems.www.authoring.html, Matt Adams
<Ma********@email.com> wrote:
As well known I could specify the text color in the body tag like:

<BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE>

What I want to achieve now is that always (!) the text of the last visited link and
the text of the link under the cursor are red. All other links should be white.

The problem with the construction above is that a visited link remains for the rest of
the session red regardless wether it was visited 17 clicks back in the history or
even just before.


(1) Not the session, but the number of days specified by the user in
_her_ browser preferences.

(2) And this is a good thing, not a problem. Users like to know
which links they have visited, so that they can more easily find
them again, _or_ so that they can not waste time going back to
something unproductive.

If you cripple navigation on your site by making visited and
unvisited links look the same, you will frustrate quite a few of
your visitors. Frustrated visitors tend to leave the frustrating
site and try a more user-friendly site. Is that what you want?

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #7
Jane Withnolastname <Ja**********************@yahoo.com> writes:
I'm getting confused again.
It seems like everyone here is all about html,
Well, I'm in comp.lang.javascript, so I am not usually all about HTML
(in this group :).
but when someone asks how to do something (not just this but,
seemingly everything) they are advised to use CSS ...
Anything related to how a document is displayed, should be done with
CSS. That kind of questions probably happen a lot, especially for
people used to using HTML to do the layout.

It makes sense to use the same group for both HTML and CSS, but if
traffic is high, it has to be split in some way.
and then when someone asks how to do something using CSS, they are
chastised for posting to an html group (hi Jukka).
Chastising people is a bad idea. Referring them to another group is
good. That is what the Followup-To header is for. Discussions do
change subject over time, and when they do, they should be guided to a
more relevant group, if such exists.
As far as the above goes, you are saying absolutely NOT to use the
html to define text and link colours but to use CSS.
I wouldn't.
Cannot both be done, as a safeguard for those browsers that don't
acknowledge CSS? Or am I reaching too far back?
I think you are. Even Netscape 4 will support the simple styles
needed here.
Don't browsers take the CSS as priority over any html? Or is that
just IE that does that?
They should. That is what the CSS specification mandates.
I apologize if this sounds like I'm trying to start a fight - I'm
only asking a question that I would truly like to know the answer
to.


Doesn't sound like that to me. However, this discussion is off-topic
for comp.lang.javascript, and I am not absolutely sure where to send
it, so I'll cross-post and set Followup-To to
comp.infosystems.www.authoring.html, even though I don't read it.

I had set Followup-To in my previous post to comp.lang.javascript,
because I expected questions to the javascript part, not the CSS :)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #8
"Daniel R. Tobias" <da*@tobias.name> writes:
Matt Adams wrote:
As well known I could specify the text color in the body tag like:
<BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE>


Setting links to the same color as regular text is a bad idea.


Though exacerbated in that example by setting both to the default
background colour of most modern graphical browsers, and not setting
something different.

--
Chris
Jul 20 '05 #9
Matt Adams wrote:
As well known I could specify the text color in the body tag like:

<BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE>
This method has been deprecated for 5 years now; you should be using CSS
instead.
What I want to achieve now is that always (!) the text of the last visited
link and the text of the link under the cursor are red. All other links
should be white.
This simply can't be done.
The problem with the construction above is that a visited link remains for
the rest of the session red regardless wether it was visited 17 clicks
back in the history or even just before.
This is a feature; this is how it is supposed to work. This is how Web
browsers have handled links for the better part of a decade.
I wanted ONLY the LAST visited link in red and - additionally -
the current link under the cursor (while the user chooses another link).

Probably I need a Javascript function.


Actually, you need to realize just how badly this will confuse users, if you
find something that "solves" this "problem".

--
Shawn K. Quinn
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matt Adams | last post by:
As well known I could specify the text color in the body tag like: <BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE> What I want to achieve now is that always (!) the text of the last visited...
5
by: Dan Jacobson | last post by:
What's Nielsen talking about in http://www.useit.com/alertbox/20040503.html http://www.useit.com/alertbox/20040510.html Can't a good browser keep track of visited vs. unvisited link colors? Is my...
18
by: Jan Tuxen | last post by:
Jakob Nielsen in his most recent Alertbox (http://www.useit.com/alertbox/20040503.html) tells web authors to change the color of visited links. I agree to his purpose: Help users understand...
8
by: Chad | last post by:
Should links automatically appear in the "visited" color as defined by the user's IE settings without having to add any special coding? I have a situation where the link was not changing color...
28
by: RAB | last post by:
When my user closes the browser, I want the visited link to change to a "fresh" never been visited link once the user (on the same machine) reopens their browser. Here is the code I am using: ...
3
by: friday13 | last post by:
Hi, I would like to set the link's "visited" pseudo-class with javascript without clicking on the link. My goal is to update the link's color (previously set in the CSS file) to be "visited"...
1
by: =?Utf-8?B?Um9nZXI=?= | last post by:
In my app I would like to change the color of the hyperlink from blue to purple when a user clicks the hyperlink in a RichTextBox. The DetectUrls property is set to True and I handle the...
0
by: =?Utf-8?B?Um9nZXI=?= | last post by:
In my app I would like to change the color of the hyperlink from blue to purple when a user clicks the hyperlink in a RichTextBox. The DetectUrls property is set to True and I handle the...
1
beacon
by: beacon | last post by:
I'm looking to reset the visited link color once another link is selected. Also, once that link takes me to a particular page, I want the font-weight for that page to be bold to indicate that it's...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.