设置访问的 url
我的页面上有一个
<a href="my_redirect_page.php?link=mylink">my_text</a>
链接,my_redirect_page.php 中有以下行:
header("Location: ".$mylink);
但是重定向后,如果我在浏览器中单击“返回”,则该链接的“my_text”不会显示为访问过的内容(紫色,而不是蓝色) )。我该如何解决这个问题?有没有办法改变 php 或 javascript 中访问的属性?
谢谢,
戴夫
I have a
<a href="my_redirect_page.php?link=mylink">my_text</a>
link on my page, and the following line in my_redirect_page.php:
header("Location: ".$mylink);
but after the redirection, if I click on back in my browser, the "my_text" for the link does not appear as visited (in purple, instead of blue). How do I work around this? Is there a way to change the visited property in php or javascript?
Thanks,
Dave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是一个很好的解决方案,但是,在 my_redirect_page.php 中:
或者类似的东西 - 页面应该加载(从而进入浏览器历史记录),然后以 0 的延迟加载目标 URL。如果由于某种原因重定向失败,用户将看到一个包含指向目标 URL 的链接的页面。
Not a terrific solution, but, in my_redirect_page.php:
Or something like that - the Page should load (thereby entering into the browser history) and then, with a delay of 0, load the targeted URL. Should, for some reason, the redirect fail, the user will see a page containing a link to the targeted URL.
我不确定这是否可行,除非您更改重定向的完成方式。
[这个问题][1]基本上是你的重复,并且共识是没有一个浏览器允许你设置伪类(如:visited)。
为用户模拟它的最简单方法是设置一个 CSS 类,该类为链接着色,使其看起来与浏览器默认或 CSS 样式访问的链接相同,您可以在视图层中轻松完成此操作,或者使用 javascript 添加该类如果链接出现在
window.history
中。您也许还可以将元素推送到 window.history 数组上,并让它们出现在浏览器历史记录中(因此被赋予 :visited 伪类),但我不确定这是否会工作。不过值得一试。
I'm not sure this is possible, unless you change the way your redirects are done.
[This question][1] is basically a duplicate of yours, and the consensus was that none of the browsers allow you to set pseudo-classes (like :visited).
The easiest way to simulate it for the user is to set a CSS class which colours the link to look the same as a browser default or CSS-style visited link, which you can easily do in your view layer or by adding the class using javascript if the link appears in
window.history
.You may also be able to push elements onto the window.history array, and have them appear in the browser history (and hence be given the :visited pseudoclass), but I'm not sure if that would work. Worth a try though.