我了解隐私问题,但在 这篇文章 Mozilla 声明他们对 querySelector() 和 getComputedStyle() 撒谎.
I understand the privacy concerns, but in this article Mozilla states that they are lying to querySelector() and getComputedStyle().
如果他们已经在对网站撒谎,那么为什么要将 :visited 限制为简单的颜色?不能使用相同的方法对网站隐藏完整的样式吗?
If they are already lying to sites, than why limit :visited to just simple colors? Couldn't full styling still be hidden from sites using the same method?
限制可以应用于访问链接的样式,防止它们以可以通过 getComputedStyle() 查询的方式影响不相关元素的布局——如果不秘密计算整个页面的布局,就无法进行欺骗,就好像所有链接都未访问一样,这在性能方面将是极其昂贵的.这与 :visited + span 之类的东西不再被应用(甚至 :visited 中仍然允许的属性)是一样的.
Limiting the styles that can be applied to visited links prevents them from affecting the layout of unrelated elements in a way that can be queried by getComputedStyle() — something that cannot be spoofed without secretly computing the layout of the entire page as if all links were unvisited, which would be extremely expensive performance-wise. This is in the same vein as things like :visited + span no longer being applied (not even the properties still allowed in :visited).
考虑一下这个概念验证,您可以在其中单击一个链接来切换模拟其访问性的类名,并查看如何在 :link 和 :visited 会影响布局:
Consider this proof-of-concept, in which you can click a link to toggle a class name that simulates its visitedness, and see how toggling between :link and :visited can affect layout:
var a = document.querySelector('a'),
p = document.querySelector('p + p');
a.addEventListener('click', function(e) {
a.className = a.className == 'unvisited' ? 'visited' : 'unvisited';
console.log('a is now ' + a.className + '; top pos of following p is now ' + p.getBoundingClientRect().top);
}, false);
a.unvisited {
font-size: 1em;
}
a.visited {
font-size: 2em; /* A property not normally allowed on :visited */
}
<p><a class="unvisited" href="#">Toggle visitedness</a>
<p>Another paragraph
这篇关于为什么浏览器会限制 :visited 选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在javascript中保护随机数?Secure random numbers in javascript?(在javascript中保护随机数?)
img src 链接中的授权标头Authorization header in img src link(img src 链接中的授权标头)
通过 Javascript 发送 Authorization Token BearerSending Authorization Token Bearer through Javascript(通过 Javascript 发送 Authorization Token Bearer)
我必须将令牌存储在 cookie 或本地存储或会话中吗Do I have to store tokens in cookies or localstorage or session?(我必须将令牌存储在 cookie 或本地存储或会话中吗?)
如何在不使用库的情况下在 javascript 中解码 jwtHow to decode jwt token in javascript without using a library?(如何在不使用库的情况下在 javascript 中解码 jwt 令牌?)
:hover:before text-decoration none 没有效果?:hover:before text-decoration none has no effects?(:hover:before text-decoration none 没有效果?)