How to apply the 'visited' in an 'a' using javascript?

0

Imagine that I have a CSS:

a {
   color: blue;
}

a:visited {
   color: red;
}

And an HTML:

<a href="#">Link</a>  

Assuming I am not aware of what color is being used, and can not manipulate browser history, how can I apply visited to a ?

That's how I can do something like this:

a = document.getElementsByTagName("a")[0];
a.href = "https://" + Math.random().toString(36).replace(/[^a-z]+/g, '');
a.visited = true;
a {
     color: blue;
  }

  a:visited {
     color: red;
  }
<a href="#">Link</a>

The desired result would be that a was in the style of visited .

    
asked by anonymous 26.04.2018 / 23:40

0 answers