0
Imagine I have a CSS:
a {
color: blue;
}
a:visited {
color: red;
}
And an HTML:
<a href="#">Link</a>
Assuming I don’t know what the color
is being used, and cannot manipulate browser history, as I can apply the visited
in a a
?
I mean, how can I do something like that:
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 the a
was in the style of visited
.
Out of curiosity, why do you need it? It does not change the usability of the application to indicate as visited a link that the user has not visited?
– Woss
You are creating a random link and want it to have the effect of
a:visited
even not visited? Wouldn’t it be easier to apply the same effect to a given link instead of changing its "status"?– Costamilam
@Andersoncarloswoss I have a Go application that uses Sciter, Sciter itself allows you to manipulate this kind of thing. I use the
active
,visited
(...) and other properties, for example if the person clicks on a button and such. Now, I’m also wanting to enable "compile" for Javascript, using Gopherjs, it works, but I can’t manipulate this kind of thing, so everything that uses these properties is broken. :(– Inkeliz
@Guilhermecostamilam The random link is only for the browser not to save as "visited" if you click. But, yes, I want it to stay with
visited
even if he hasn’t visited. If there’s a way to pick up the :visited style and apply it, it would give the same desired result. What I want is for the visited style to be applied at any time. If there is a way to copy the visited style and apply it it would be enough. What I want, after all, is to avoid changing the existing code, reusing everything and just "passing to Javascript".– Inkeliz
I ran some tests and the only thing I could answer is how it doesn’t work, I believe selectors like
:visited
,:hover
among others cannot be accessed (at least not easily)– Costamilam
Then I thought the
visited
could be a privacy issue, it would give to know which websites were visited. But, some way to "write-only" would still be useful. I guess by the looks of it I’ll be moving everything to some class of the.active
,.visited
(...) and apply it to the element, but it wasn’t something I wanted. :(– Inkeliz