Javascript找到链接的颜色 [英] Javascript Find The Colour Of Link

查看:97
本文介绍了Javascript找到链接的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我遇到的问题基本上可以解决,我有一个HTML外部网站列表(如下所示).

So the issue I'm having basically comes down, I have a list of external websites in HTML (as seen below).

<a id="listitem0" href="http://google.com.au/">http://google.com.au/</a><br />
<a id="listitem1" href="http://stackoverflow.com/">http://stackoverflow.com/</a><br />
<a id="listitem2" href="http://kbbdigital.com.au/">http://kbbdigital.com.au/</a><br />
<a id="listitem3" href="http://netreach.com.au/">http://netreach.com.au/</a><br />

其中一些我已经访问了&其他我没有的样式,因此我有CSS样式可以帮助识别访问过的对象还是未访问过的对象(如下所示).

And some of them I have visited & others I haven't, so I have CSS styling to help identify the visited vs not visited (as seen below).

<style type="text/css">
    a {
    color:#999999;
    background-color:#000;
}

a:visited {
    color:#00FF00;
    background-color:#30F;
}
</style>

从视觉上我可以看到哪些网站具有&尚未访问过,但是当我运行基本的javascript行时,它无法拾取文本的颜色或背景色(下面的代码),它仅提供空白输出.

Visually I can see which websites have & haven't been visited, but when I run a basic javascript line it can't pick up the colour of the text or the background colour (code below), it just provides blank output.

<script type="application/javascript">
alert(document.getElementById("listitem0").style.backgroundColor);
alert(document.getElementById("listitem0").style.color);
</script>

有人知道为什么它不能根据先前的CSS设置来拾取文本的颜色吗?并有解决方案吗?

Does anyone know why it can't pick up the colour of the text based on the CSS set earlier? And is there solution to get this?

我正在使用Firefox 27.0.1来运行这些测试,但是也尝试过使用其他浏览器,但是会收到相同的问题.

I'm using Firefox 27.0.1 to run these tests, but have tried other browsers as well, but receive the same issue.

推荐答案

已禁用对访问链接的检测作为一种隐私措施.谢谢你.

The detection of visited links is disabled as a privacy measure. And thanks for that.

参考与CSS相关的隐私相关更改:已访问

简而言之,这是无法完成的.话虽这么说,可能会有骇客入侵,但最有可能很快将其修补,结果是不可靠.

In short, it can't be done. That said, there might be hacks, but those would most likely quickly be patched and as a result being unreliable.

据我了解,这是在大多数浏览器中实现的.

From what I read, this is implemented in most browsers.

例如,使用计时攻击是如何破解历史的一个例子.简而言之:

As an example of how one could hack the history is using timing attacks. That is in short:

  1. 您想知道用户是否访问过 aleister_crowley.com
  2. 您找到一个所有用户都将缓存的商品,例如 aleister_crowley.com/profile.jpg
  3. 您添加了脚本以将该图片加载到您的网站中,并花费了多长时间.

如果用户访问了该页面,则由于用户浏览器中的缓存,图像将快速加载.因此,您可以估计用户实际上已经访问了该页面.

If user has visited the page the image would load quickly due to caching in the users browser. As such you can estimate the user has, in fact, visited that page.

本文的更多内容.

那么,当然,您的网站已转为阴暗面时就是这种情况.

Then of course, this would be a case were your site has flipped to the dark side.

这篇关于Javascript找到链接的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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