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

F

friday13

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!
 
F

friday13

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.
 
T

tsukasakun

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
 
F

friday13

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top