How to change visited links into unvisited links w

2019-08-16 22:59发布

问题:

Is there any way to make a visited link back to unvisited without deleteing anything from hystory? I want to do that on a forum, when someone replies in a topic, it has to turn that topic link into unvisited.

I am using this css:

a.newold:visited
{color:#999999;}
a.newold:link
{font-weight: bold;}

and there is the list of topics:

<a class="newold" href="read_topic.php?id=ID">TITLE</a>

The thing is: When I click on a topic, it will be automatically updated as visited?

I want something, (if is possible) that when I add a reply INSIDE that topic, its link will be updated as unvisited

More information about what I am seeking:

Example: The topic name will be: TEST. The topic first is unvisited, and it looks like: TEST;

I click on it, I read it, it will look like: TEST;

Then I add a reply in that topic;

The topic will look unvisited again: TEST;

I think this is as clear as it can be.

If I use some other variable like $user seen topic_id, it will be bad, because it is a large request, so I wonder if there is something that can be done without database requests.

回答1:

You can control styles of visited linked with :visited pseudo-class. You can defined necessary color settings for visited links and when you need to mark link as replied you can add some CSS class to it, and defined CSS rules like this:

a.updated:visited {
    color: #00E;
}

Here is a little demo:

a.updated:visited {
    color: #00E;
}
<a href="http://stackoverflow.com">Visited without class</a>
<a class="updated" href="http://stackoverflow.com">Visited with class</a>



回答2:

When posting to a forum, you could add a query to the link which would cause it to be treat as a new link.

So imagine the link is /topic1 if you answer the question, you could have it attach a query to the link for that user, so it shows back up as a new link, eg. /topic1?=answered

If you needed it to change every time, you would probably need to add a time stamp to this also, so that it is constantly unique every time you answer a question