重置链接上的访问状态 [英] Resetting visited status on links

查看:69
本文介绍了重置链接上的访问状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法可以重置链接上的访问状态?

Is there any way you can reset the visited status on links?

情况是这样的:在一个内网网站上,我们想要很多链接仅在一段时间内具有已访问状态的链接。因此,我正在寻找一种方法来操纵链接的访问状态。

The scenario is this: On an intranet-site which naturally has a lot of links we want a link to have the status of "visited" for a set period of time only. I am therefore looking for a way to manipulate the visited status of links.

这可行吗?它当然应该是跨浏览器。

Is this doable? It should be cross-browser of course.

ETA:客户端解决方案是完全可以接受的。首选偶数..: - )

ETA: Client-side solutions are perfectly acceptable. Preferred even.. :-)

ETA-2:允许使用Cookie。这里没有禁止: - )

ETA-2: Cookies are allowed. No holds barred here :-)

推荐答案

当浏览器选择应用:已访问 CSS伪类

Links appear as "visited" when the browser chooses to apply the :visited CSS pseudo-class.

重置链接到未访问状态的客户端方式是(以某种方式)清除浏览历史记录。我会非常惊讶地发现有一种便携式方法可以做到这一点。它还有令人不快的副作用,例如削弱历史敏感的智能位置栏的行为,例如Firefox 3中的那种。

The client-side way to reset links to the unvisited state is to (somehow) clear the browsing history. I would be very surprised to learn there is a portable way to do it. It also has unpleasant side effects such as crippling the behavior of history-sensitive smart location bars such as the one in Firefox 3.

正如Drew Noakes建议的那样,服务器端方法是向链接添加一些噪声查询参数,并定期更改查询参数。这只会给出您想要的行为的不正确的近似值。要获得正确行为,您需要跟踪每个用户服务器端访问过的页面的历史记录,这样您就可以在必要时间之后更改特定页面的噪声参数。

As Drew Noakes suggested, a server-side way is to add some noise query parameters to the links, and periodically change the query parameter. This only gives a bad approximation of the behaviour you want. To get the "correct" behavior you'd need to track the history of visited pages per user server-side, so you can change the noise parameter for a specific page only after the requisite time.

所有人都说,实际上尝试重置链接上的访问状态可能是一个坏主意。

All said, it's very probably a bad idea to actually try to "reset the visited status on links".

我认为更好的解决方案是调整页面样式使得:visited伪类呈现与:link伪类相同。然后保留每个用户访问过的链接的服务器端历史记录,并使用显式已访问类调整链接显示。

I think a better solution would be to tweak the page style so the :visited pseudo class renders the same as the :link pseudo-class. Then keep a server-side history of visited links per user, and adjust the display of links using an explicit visited class.

如果您没有方便用户身份,并且不想要求登录,则可以随时使用随机持久性cookie。

If you do not have the user identity handy, and do not want to require login, you can always use a random persistent cookie.

这篇关于重置链接上的访问状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆