473,763 Members | 8,980 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
3 17092
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 #2
On 26 Aug 2003 12:53:40 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com > wrote:
Ma********@ema il.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>


I'm getting confused again.
It seems like everyone here is all about html, but when someone asks
how to do something (not just this but, seemingly everything) they are
advised to use CSS ... and then when someone asks how to do something
using CSS, they are chastised for posting to an html group (hi Jukka).
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. Cannot both be
done, as a safeguard for those browsers that don't acknowledge CSS? Or
am I reaching too far back? Don't browsers take the CSS as priority
over any html? Or is that just IE that does that?
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.
Thanks!
Jul 20 '05 #3
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 #4

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

Similar topics

9
52395
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...
12
15322
by: jfburr | last post by:
very simple thing (I hope) I've got a css style sheet that starts like this: ______________ A:link { color: cc9933; }
2
1655
by: Dot net work | last post by:
I have a 3rd party link button control that when clicked does not retain it's visited color status on postback. (Actually, the first control on the form does, but all others do not.) When I hover the mouse over the link button control, I can see the custom javascript in the browser's status bar. It puts a wrapper around the usual __doPostBack function call. Is this wrapper causing IE to get confused as to the visited status of the...
8
2925
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:
22
4706
by: subashinicse | last post by:
hi to everybody, am new to this forum.. am working with J2ee,i have a jsp page where i have some links,i want to change the link color when it is active,and it has to turn back to original color when the other link is active, i tried with style sheets,when i click on the link its changing its color,but when the form loads ,its turning back to the original color,i want the color to stay even after the form loads. can anybody help me...
8
11254
by: Jeff | last post by:
ASP.NET 2.0 I'm wondering how to set the color of a visited HyperLinkField (the link text) in a GridView?? Here is the markup of the HyperLinkField I have problems with: <asp:HyperLinkField HeaderText="Subject" Text="Subject" DataTextField="Subject" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/Templates/View.aspx?id={0}" HeaderStyle-CssClass="columnStyle" ItemStyle-CssClass="columnStyle" />
3
4902
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:
2
2617
by: Garima12 | last post by:
There is htm page. In its body I am calling a class from stylesheet called TaskbarStyle(classname). Now I want to change the color of hyperlink in this page as well as their active link color. I am calling 2 stylesheets on this htm page. code of htm page: <BODY class="TaskbarStyle" TEXT="Black" bottommargin="0" centermargin="0" rightmargin="0" topmargin="0"> code of stylsheet which contains TaskbarStyle class; .TaskbarStyle { ...
2
3999
by: ghjk | last post by:
In my php web site I have left pannel which is having links to all pages. I want to change link color or background color when clicked. How can I do that? This is my current code. Could someone help me? $array1 = array("A"=>'A.php',"B"=>'B.php', "C"=>'C,"D"=>'D.php',"E"=>'E.php',"F"=>'F.php'); $arraypre = array(); switch ($type){ case "User1":$arraypre = array('G'=>'G.php','H'=>"H.php",'I'=>"I.php");break; case...
0
9387
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10148
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
10002
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...
1
9938
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
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
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.