473,508 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to set link's "visited" property/pseudo-class without clicking on the link

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:
var obj = document.getElementById("idOfMyLink");

//obj.visited=true; // NO
//obj.style.visited=true; // NO
//obj.click(); // NO, performs a click and takes me away from
current page

/*
// Setting the src of an iframe on the same page, trying to
"stuff" this URL into browser's "History"

var theFrame = document.getElementById("myiframe");
theFrame.src = obj.href;

// NO. The iframe does go to correct URL, but the link's color
doesn't update.
*/

Any ideas?

Thanks for your help!

Apr 27 '07 #1
3 4874
On Apr 27, 3:23 pm, friday13 <vbo...@gmail.comwrote:
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:

var obj = document.getElementById("idOfMyLink");

//obj.visited=true; // NO
//obj.style.visited=true; // NO
//obj.click(); // NO, performs a click and takes me away from
current page

/*
// Setting the src of an iframe on the same page, trying to
"stuff" this URL into browser's "History"

var theFrame = document.getElementById("myiframe");
theFrame.src = obj.href;

// NO. The iframe does go to correct URL, but the link's color
doesn't update.
*/

Any ideas?

Thanks for your help!
This is not a self-"bump"... just a follow-on question with a
possible work-around.
So this is a hack, but a way to SORT OF get the link "visited" is is
to open a new window with that URL:

var win = window.open( url,'mywindow','width=100,height=200');

And then close it right away.

win.close();

But the link-color is NOT updated until I refresh the page.

So this generates a 2nd question:

Is there any way to FORCE the link to update its color??

Thanks.

Apr 28 '07 #2
On Apr 28, 12:23 am, friday13 <vbo...@gmail.comwrote:
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:

var obj = document.getElementById("idOfMyLink");

//obj.visited=true; // NO
//obj.style.visited=true; // NO
//obj.click(); // NO, performs a click and takes me away from
current page

/*
// Setting the src of an iframe on the same page, trying to
"stuff" this URL into browser's "History"

var theFrame = document.getElementById("myiframe");
theFrame.src = obj.href;

// NO. The iframe does go to correct URL, but the link's color
doesn't update.
*/

Any ideas?

Thanks for your help!
You could define a class in the CSS then just change the class of the
link ;p

Apr 28 '07 #3
On Apr 27, 5:00 pm, tsukasa...@gmail.com wrote:
On Apr 28, 12:23 am, friday13 <vbo...@gmail.comwrote:


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:
var obj = document.getElementById("idOfMyLink");
//obj.visited=true; // NO
//obj.style.visited=true; // NO
//obj.click(); // NO, performs a click and takes me away from
current page
/*
// Setting the src of an iframe on the same page, trying to
"stuff" this URL into browser's "History"
var theFrame = document.getElementById("myiframe");
theFrame.src = obj.href;
// NO. The iframe does go to correct URL, but the link's color
doesn't update.
*/
Any ideas?
Thanks for your help!

You could define a class in the CSS then just change the class of the
link ;p- Hide quoted text -

- Show quoted text -
@tsukasa

Ok, so how do I know the "color" value of visited links for that page?

I'm trying to write a greasemonkey script that could apply to pages
that I don't own/create.

Question 3:

How do I get the value of "a:visited" that is defined in a CSS file?
Or what if it's not [user is using the regular blue/purple combination
from browser?

Thanks.

Apr 28 '07 #4

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

Similar topics

14
2654
by: Good Man | last post by:
Hi There A client of mine has some banner ads placed on the net. Instead of relying on the sites the ads are posted on tell us how many clicks they are getting, we wanted to track the number...
2
2061
by: Jason Sauer | last post by:
We use "FOR XML EXPLICIT" and "OPENXML" heavily on our SQL 2000 Advanced server. Every now and then we get an "Undeclared Tag ID" error (SQL Error #6806). If I open the stored procedure, modify it...
15
2489
by: Rob Evans | last post by:
Is there a way of stopping " - Microsoft Internet Explorer" being added to the browser window title ? eg, I want it to say: My Website Name and not My Website Name - Microsoft Internet...
1
3795
by: Rob Oaks | last post by:
I have noticed the presence of declarations like this: UNKNOWN { height: 30px } in the style sheets used by some highly regarded CSS folks. This declaration usually (but not always) follows...
9
2960
by: Nicolae Fieraru | last post by:
Hi All, I try to use Request.ServerVariables("HTTP_REFERER") in a script and I discovered it doesn't work as expected. I use XP with SP2 and I created a link on a web site which points to an asp...
8
2035
by: Jim G. | last post by:
I am attempting to develop an application for a client that will monitor Web Traffic on a Users PC (from a tray application that the user downloads) - I am NOT interested in blocking or limiting...
11
1723
by: Ux | last post by:
Hi I'm a newbie at JS and I'd like to know, from the expert JS-er, which are the "things" they consider a *must have* (or known/visited/read...) for a professional JS developer. This will help me...
4
2037
by: Irena | last post by:
Hi all there, I have developed an ASP script that is able to read the structure of an Ms Access database ( via object objConn.OpenSchema(27) ) and to identify the foreign Keys columns and tables...
2
1024
by: epigram | last post by:
This is probably a more general HTML question, but here it goes. We're creating an asp.net app and noticed that sometimes if an aspx page has already been visited (say, in a given session) that...
18
1811
by: google.1.jvmail | last post by:
I have over 10 years strong experience coding in VBA, developing complex multi-user applications in MS Access (all versions), have worked with security, replication, and whole bunch of other...
0
7132
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...
0
7336
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,...
0
7401
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...
0
7504
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...
0
5640
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,...
0
3211
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...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
432
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...

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.