Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > how to set link's "visited" property/pseudo-class without clicking on the link

Reply
Thread Tools

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

 
 
friday13
Guest
Posts: n/a
 
      04-27-2007
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!

 
Reply With Quote
 
 
 
 
friday13
Guest
Posts: n/a
 
      04-27-2007
On Apr 27, 3:23 pm, friday13 <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
 
 
 
tsukasakun@gmail.com
Guest
Posts: n/a
 
      04-28-2007
On Apr 28, 12:23 am, friday13 <(E-Mail Removed)> wrote:
> 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

 
Reply With Quote
 
friday13
Guest
Posts: n/a
 
      04-28-2007
On Apr 27, 5:00 pm, (E-Mail Removed) wrote:
> On Apr 28, 12:23 am, friday13 <(E-Mail Removed)> wrote:
>
>
>
>
>
> > 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
I want to create a link "e-mail this page to a friend" on clicking this link i want to send the URL of that current page to a friend pavi Javascript 0 01-13-2006 12:10 PM
How to open a site without clicking on a link for it? Net Javascript 4 02-09-2005 11:27 PM
Set the width of the edit textbox after clicking on Edit link in datagrid... Sharon McCarty ASP .Net Datagrid Control 0 11-24-2004 06:41 PM
I want to be able to access the internet by opening my browser and not right clicking and then clicking connect. James Johnson Computer Support 1 05-15-2004 03:40 AM



Advertisments