473,602 Members | 2,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 52369
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********@emai l.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 (lastClickedLin k) {lastClickedLin k.style.color = "";}
lastClickedLink = this;
this.style.colo r = "red";
}
function makeMemory() {
for (var i=0; i<document.link s.length; i++) {
var link = document.links[i];
if (link.addEventL istener) {
link.addEventLi stener("click", rememberLink,fa lse);
} else if (link.attachEve nt) {
link.attachEven t("onclick",rem emberLink);
} else {
link.onclick=re memberLink;
}
}
}
<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="makeMem ory()">
---

Good luck.

Followup-To set to comp.lang.javas cript.
/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********@ema il.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********@ema il.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*@jabb er.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.infosystem s.www.authoring.html, Matt Adams
<Ma********@ema il.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************ **********@yaho o.com> writes:
I'm getting confused again.
It seems like everyone here is all about html,
Well, I'm in comp.lang.javas cript, 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.javas cript, and I am not absolutely sure where to send
it, so I'll cross-post and set Followup-To to
comp.infosystem s.www.authoring.html, even though I don't read it.

I had set Followup-To in my previous post to comp.lang.javas cript,
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.nam e> 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
17076
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 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...
5
2409
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 site deficient as I have not messed with link colors? Does Nielsen address why all this can't be left up to the browser? Are link colors supposed to be special, like background images, to make a big impression?
18
10734
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 where they have been. I also agree to the background: Too many web authors keep uniform link colors or their pages, thereby confusing the users. What I have a hard time agreeing to is his conclusion that web authors should deliberately change the...
8
2917
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 until I added the following style: .vl:visited{color:#808080;} And then referenced this style in my Anchor:
28
2650
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: /* buttons.css */ body { font-family: Verdana, sans-serif; color: black; background-color: white; } h1 { color: navy; }
3
4887
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" without actually clicking on the link and then clicking "back" in the browser. Does anyone know how? Here are the following things I've already tried to no avail:
1
2269
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 RichTextBox1.LinkClicked event to launch a browser window. That works fine. The problem is that once the DetectUrls property is True the RichTextBox control shows the link in blue even if I select the text and change the SelectionColor to purple. For...
0
2152
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 RichTextBox1.LinkClicked event to launch a browser window. That works fine. The problem is that once the DetectUrls property is True the RichTextBox control shows the link in blue even if I select the text and change the SelectionColor to purple. For...
1
4098
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 the page you're looking at. Now, if the links have never been visited before, they are blue. If you hover over the links they turn light blue. I want the user to be able to select the link and it take you to that page. On that page, I want the link...
0
7993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8404
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8268
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6730
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.