Google chrome a:访问过的背景图像不起作用

发布于 2024-09-24 11:57:36 字数 1756 浏览 3 评论 0原文

(在开始之前我应该​​说是的,我已经完成了所有的愚蠢检查,是的,该链接在我的历史记录中并且已被访问过等)

我使用的是 Chrome 版本 6.0.472.63,尽管这适用于所有浏览器很重要。

它适用于 Firefox、IE 和 Opera。

基本上我想做的就是在链接已被访问时更改链接的背景图像。

我已经做了很多试验和错误测试,所以请耐心等待我举多个例子。

这就是我最初

.forum_box .title a {
 background-image:url(../images/f_unread.png);
 background-position:10px center;
 background-repeat:no-repeat;
 background-color:transparent;
 color:#2D4054;
 font-size:14px;
 padding:10px 12px 10px 44px;
 text-decoration:none;
 display:block;
 font-weight:bold;
}
.forum_box .title a:visited {
 background-image:url(../images/f_read.png);
}

在除 Chrome 之外的所有浏览器中都可以使用的内容。接下来我尝试将其设置为颜色而不是图像。

.forum_box .title a:visited {
 background-color:red;
}

同样,但是我将链接更改为 #fff 而不是透明,并且访问的链接更改为红色,因此显然,背景颜色仅在为父级设置背景颜色时才有效。

.forum_box .title a {
 background-image:url(../images/f_unread.png);
 background-position:10px center;
 background-repeat:no-repeat;
 background-color:#fff;
 color:#2D4054;
 font-size:14px;
 padding:10px 12px 10px 44px;
 text-decoration:none;
 display:block;
 font-weight:bold;
}
.forum_box .title a:visited {
 background-color:red;
}

但它仍然没有解决我的形象问题。因此,在最后一次尝试中,我尝试了这一点,希望由于某种原因 Chrome 只能在两者都存在相同属性时才能工作。

.forum_box .title a {
 background:#fff url(../images/f_unread.png) no-repeat 10px center;
 color:#2D4054;
 font-size:14px;
 padding:10px 12px 10px 44px;
 text-decoration:none;
 display:block;
 font-weight:bold;
}
.forum_box .title a:visited {
 background:#fff url(../images/f_read.png) no-repeat 10px center;
}

这也不起作用,并且继续在 Firefix、Opera 和 IE 上工作。所以我来到Stack Overflow很困惑。

任何帮助将不胜感激!

更新: 我已经尝试了 jQuery 解决方案,尽管它仍然不起作用。尽管有 :visited 链接,我可以通过将字体颜色更改为红色来确认其访问状态。 jQuery('a:visited').length 返回 0。

(before I start I should say yes, I have done all the stupidity checks, yes the link is in my history and has been visited etc)

I'm using Chrome version 6.0.472.63, although it's important that this works on all browsers.

It works on Firefox, IE and Opera.

Basically all i'm trying to do is change the background image of a link if the link has been visited.

I've done alot of trial and error testing so bear with me for multiple examples.

This is what I had originally

.forum_box .title a {
 background-image:url(../images/f_unread.png);
 background-position:10px center;
 background-repeat:no-repeat;
 background-color:transparent;
 color:#2D4054;
 font-size:14px;
 padding:10px 12px 10px 44px;
 text-decoration:none;
 display:block;
 font-weight:bold;
}
.forum_box .title a:visited {
 background-image:url(../images/f_read.png);
}

Works in every browser except Chrome. Next I tried just making it a colour rather than image.

.forum_box .title a:visited {
 background-color:red;
}

Same again, however I changed the link to #fff instead of transparent and the visited link changed red, so apparently the bg colour only works if you set a bg colour for the parent.

.forum_box .title a {
 background-image:url(../images/f_unread.png);
 background-position:10px center;
 background-repeat:no-repeat;
 background-color:#fff;
 color:#2D4054;
 font-size:14px;
 padding:10px 12px 10px 44px;
 text-decoration:none;
 display:block;
 font-weight:bold;
}
.forum_box .title a:visited {
 background-color:red;
}

However it still doesn't solve my image problem. So in one final attempt I tried this in the hope that for some reason Chrome would only work when the same properties where present in both.

.forum_box .title a {
 background:#fff url(../images/f_unread.png) no-repeat 10px center;
 color:#2D4054;
 font-size:14px;
 padding:10px 12px 10px 44px;
 text-decoration:none;
 display:block;
 font-weight:bold;
}
.forum_box .title a:visited {
 background:#fff url(../images/f_read.png) no-repeat 10px center;
}

That didn't work either and again continued to work on Firefix, Opera and IE. So I come here to Stack Overflow very confused.

Any help would be greatly appreciated!

UPDATE:
I've attempted a jQuery solution, although it still doesn't work. Despite having :visited links and I can confirm their visited state by changing the font color to red. jQuery('a:visited').length returns 0.

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

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

发布评论

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

评论(5

三五鸿雁 2024-10-01 11:57:37

这里同样的问题。
在 a:visited 上更改 CSS Sprite 中的背景位置对我来说在 Firefox 3.6 中有效,但在 Chrome 6 中无效。

但可能很快它也会在 Firefox 中停止工作。 (也许适用于 FF 4?)

这是一个隐私问题,您可以在此处阅读 Mozilla 的相关文章(2010 年 3 月)http://hacks.mozilla.org/2010/03/privacy-lated-changes-coming-to-css-vistited/
还有错误:
https://bugzilla.mozilla.org/show_bug.cgi?id=147777#c160

我认为唯一可能的解决方案是创造性地使用背景颜色而不是图像。

Same problem here.
Changing background-position in a CSS Sprite on a:visited is working for me in Firefox 3.6 but not in Chrome 6.

But probably soon it will stop working in Firefox too. (maybe for FF 4?)

It's a privacy problem, and you can read here a Mozilla article about it (March 2010) http://hacks.mozilla.org/2010/03/privacy-related-changes-coming-to-css-vistited/
And the bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=147777#c160

I think only possible solution is to use creatively the background-color instead of images.

追风人 2024-10-01 11:57:37

这可能是一个安全问题。
查看 Mozilla 上的帖子安全博客。
我当然可以想象他们会怎么做。

It's probably a security issue.
Check this post on the mozilla security blog.
I can certainly imagine how they would do it.

追我者格杀勿论 2024-10-01 11:57:37

Chrome 似乎禁用了 :visited 的 CSS(颜色除外)。

这将是为了防止历史嗅探漏洞。

请参阅http://www.azarask.in/blog/post/socialhistoryjs/

Chrome appears to have disabled css for :visited ( except for color ).

This would be to prevent the history sniffing exploit.

See http://www.azarask.in/blog/post/socialhistoryjs/

您可能需要在您的 img url 周围添加单引号...
浏览器很有趣,他们什么时候关心引号,什么时候不关心......

You might need your single quotes around your img url...
Browsers are funny about when they do care about quotes and when they don't....

杀手六號 2024-10-01 11:57:37

这样做是出于安全原因,因为可以加载许多不同的图像并检测用户访问了哪些链接、发送特定请求的任何属性或加载特定资源,具体取决于用户访问的内容在技术上是可见的作为一个安全问题,因为它可能泄露用户的个人利益。

https://blog.jeremiahgrossman.com/2006/ 08/我知道-youve-been.html

This is done for security reasons, as it was possible to load a lot of different images and detect which links the user had visited, any property sending an specific request, or loading a specific resource, depending on what the user has visited is technically seen as a security issue, as it can leak personal interests of the user.

https://blog.jeremiahgrossman.com/2006/08/i-know-where-youve-been.html

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