:visited 伪类何时应用于超链接

发布于 2024-09-16 07:07:12 字数 265 浏览 12 评论 0原文

我对 :visited 伪类有一些疑问:

  • 浏览器根据什么决定何时应将 :visited 伪类应用于超链接?
  • 他们是从浏览器的页面历史记录中获取此信息,还是按会话或其他地方存储这些信息?
  • 是否可以(对于网页开发人员)控制 :visited 伪类应用于超链接的时间?

(注意:我并不是想解决实际问题,我只是想知道它是如何工作的)

I have some questions about the :visited pseudo-class:

  • Based on what do browsers decide when the :visited pseudo-class should be applied to a hyperlink?
  • Do they take this information from the browser's page history or is it stored per-session or somewhere else?
  • Is it possible (for the developer of a web page) to control for how long the :visited pseudo-class should be applied to hyperlinks?

(Note: I'm not trying to solve an actual problem, I'm just wondering how it works)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

在巴黎塔顶看东京樱花 2024-09-23 07:07:12

当根据浏览器历史记录访​​问链接时应用它。清除您的历史记录将清除访问过的状态。据我所知,没有“超时”。

It's applied when a link has been visited based on the browser history. Clearing your history will clear the visited state. There's no "timeout", as far as I know.

计㈡愣 2024-09-23 07:07:12

通常存储在浏览器的页面历史记录中(不是每个会话,除非在某种隐私模式的情况下)。

它只是检查该链接是否存在于历史记录中,如果存在,则为 :visited。据我所知,你无法以任何方式控制它的应用时间。

It's usually stored in the browser's page history (not per session, except in the case of some sort of privacy mode perhaps).

It simply checks if that link exists in the history, if so it's :visited. As far as I'm aware, you can't control how long it's applied in any way.

时光病人 2024-09-23 07:07:12

当目标发生变化时,您可以通过更改链接本身来控制它,从而对您有利。例如,我见过一些留言板软件会将消息计数附加到其首页上的主题链接中,这样当新消息出现在其中时,您访问过的链接就会变成未访问过的。

You can kind of control it to your advantage by changing the link itself when its target changes. For example, I've seen some message board software that would append the message count to its topic links on the front page, so that the links you have visited would become unvisited when a new message appears in them.

〗斷ホ乔殘χμё〖 2024-09-23 07:07:12

:visited 参数存储在用户历史文件中,并且只能在本地删除。
无法从服务器控制它,

为什么要为其设置超时?也许还有另一种方法可以得到你需要的东西。

您可以做的是在链接中创建一个随机参数,如下所示:

http://www.yourdomain.com/?<random argument>

这样链接总是不同的,定向到相同的链接,然后您只需丢弃该参数即可。

@编辑是的,这是可能的,如果您设置一个cookie并且每个用户检查每个链接上次设置cookie的时间(包括参数),并且如果时间>到你想要的时间,刷新参数

The :visited argument is stored in a users history file, and can only be removed locally.
There is no way to controll that from a server

why do you want to set a timeout for it? maybe there is another way to get what you need.

what you can do is create a random parameter in your link like:

http://www.yourdomain.com/?<random argument>

this way the link always difers, is directed to the same link and then you just throw away the parameter.

@edit yes, it is possible, if you set a cookie and the per user check the last time the cookie was set per link(include the parameter), and if time > the time you want, refresh the parameter

(り薆情海 2024-09-23 07:07:12

好吧,除了一件事之外,几乎所有内容都已涵盖。
什么时候应用?
当目标页面有 onload 事件时。所以不是立即。
如果您在后台的新选项卡中打开链接,您会在切换样式之前看到一些延迟。这正是外部页面加载所需的时间以及浏览器存储历史记录/触发更改所需的时间。

well almost everything has been covered except one thing.
when does it get applied?
when the target page has its onload event. so not immediately.
if you open the link in a new tab in the backgorund you will see some delay before it switches its style. tahts exactly the time the external page takes to load and for the browser to store history/trigger the change.

揽月 2024-09-23 07:07:12

It only applies to hyperlinks (<a href>), and when an entry is found in the browser history (not session).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文