View Full Version : How to simulate an a:visited with JS onClick

05-13-2009, 01:37 PM

I have had a breeze through the search results and tried modifying some scripts but with no real success yet.

What I am trying to do and why?
Create a visited appearance (style) to links using onClick
Why > I am using lightbox to call content for a design but require the links to be styled with
text-decoration: line-through; once they have been visited.
The JS script for a lot of lightbox versions will not recognise these links as visited (for some reason not known to me).

I imagine the structure is something along the lines of:

function = style

Some nippy code to solve this would be ace. Thanks for your time.


05-13-2009, 01:57 PM
Any chance of some more details? Can't quite get a handle on what you need to do.

05-13-2009, 02:05 PM
I would like to add a style to a link once it has been clicked. I would usually use CSS to create an a:visited style.

I this problem the a:visited will not work because the page linked up is being served/loaded through lightbox

In particular I would like to style the link with 'line-through' once it has been clicked.

Hope that explains it a bit better.

05-13-2009, 02:21 PM
In its simplest implementation:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.visited {text-decoration: line-through;}
<a href="#null" onclick="this.className='visited'">foo</a>

More systematic ways of doing this, but without a document to look at (or some more specific information) hard to design anything.

05-13-2009, 02:31 PM
This is just the ticket.

Simple and easy. Perhaps I should buy a JS book!

Thanks very much for your help Adios