Question: FF2 (at least) doesn't mark as link as :visited if it triggers the onclick handler without following the href. I'm using onclick to fetch data from a server and modify the page and the link styling seems appropriate here. But the link is not marked as visited.

Is there a cross-browser way to mark the link as visited? Failing that, is there a way to determine the browser's a:visited styling and apply it to the link?

Thanks to all who replied.

Looks like the **answers** are:

* *Is there a cross-browser way to mark the link as visited?*  

No, there's no way to do this. Links are identified as visited if the href is in the browser history.
 * *Is there a way to determine the browser's a:visited styling?*  

No, not via javascript alone.

Answer: 
Strictly speaking, there's no such thing as a "visited" state for individual links. It's the URLs themselves that are interpreted as "visited" by the browser. Any links that point at a URL in the browser's history will receive styling as defined by the :visited pseudo-style in your CSS.

You could try to fake it by setting the location of a hidden iframe to the desired URL, but that won't force the current page to re-draw so I doubt you'd see the :visited style updates w/o a refresh.

For the 2nd part of your question, I'd probably go with Jordan Jones' answer.
Is there a way to determine the browser's a:visited styling?

I would say yes since the current document is visited and you can find it's link color like this:-

```
alert(mys_getLinkColor(top.location))

function mys_getLinkColor(href) {
var x, body, res=''
x = document.createElement('a')
x.href = href
body = document.getElementsByTagName('body')[0]
body.appendChild(x)
if(x.currentStyle) {
   res = x.currentStyle.color
}
else if(window.getComputedStyle) {
   res = window.getComputedStyle(x,null).color
}
return mys_rgbToHexColor(res) }

function mys_rgbToHexColor(v) { 
// E.g. 'rgb(5,2,11)' converts to "#05020b". All other formats returned unchanged.
var i
v = v.split('(')
if(!v[1]) return v[0]
v = v[1].replace(/ /g, '').replace(/\)/, '')
v = v.split(',')
for(i=0; i<v.length; i++) {
   v[i] = Number(v[i]).toString(16)
   if(v[i].length==1) v[i] = '0' + v[i]
}
return '#'+v.join('')}

```