Yeah, see here for an example. It uses getComputedStyle to find out if a link has been visited. There's also a variant of this hack that doesn't require scripting.
The relevant part of the example is this (modified for clarity):
a:visited {
color: #00f;
}
var link = document.createElement('a');
link.href = 'http://example.com/';
document.body.appendChild(link);
var color = document.defaultView.getComputedStyle(link, null).getPropertyValue('color');
// check for visited
if (color == "rgb(0, 0, 255)") {
alert(link.href + ' has been visited');
}
May I ask what do you need it for?
Edit: WRT #2, you could open the link in an iframe. That would mark it as visited in the browser history. Like so:
var iframe = document.createElement('iframe');
iframe.src = 'http://example.com/';
document.body.appendChild(iframe);
Edit: You can create new CSS rules with JS. There's a jQuery plugin to make it more simple. Basically, you would do it like this:
Yeah, see here for an example. It uses
getComputedStyle
to find out if a link has been visited. There's also a variant of this hack that doesn't require scripting.The relevant part of the example is this (modified for clarity):
May I ask what do you need it for?
Edit: WRT #2, you could open the link in an
iframe
. That would mark it as visited in the browser history. Like so:Edit: You can create new CSS rules with JS. There's a jQuery plugin to make it more simple. Basically, you would do it like this:
How about doing it through CSS?