use*_*628 6 javascript firefox jquery google-chrome visited
我正在使用Chrome和Firefox的用户脚本,我正在检查用户访问过的链接.我有
a{
color: blue;
}
a:visited{
color: red !important;
}
Run Code Online (Sandbox Code Playgroud)
在页面加载后立即导入我的CSS.我访问过的页面上的a-links为红色,而不是默认的蓝色.然后我用:
alert(window.getComputedStyle(document.getElementById("myLink"), null).getPropertyValue("color"))
Run Code Online (Sandbox Code Playgroud)
在每个链接上,它们都为Firefox中的访问链接返回红色,但在Chrome中它们都返回蓝色.
我想知道如何使用javascript与Chrome实现查找访问过的链接.Jquery代码或普通的javascript代码很好.提前致谢.
A_horse_with_no_name是对的.该:visited安全问题是由浏览器厂商固定的2010年,一记漂亮的演示后(Spyjax ;不再上)证明,任何网页,可以发现无论你访问过的任何给定的URL.您可以验证getComputedStyle链接上的链接不再返回:visited颜色 - 即使在同一个域中:
// Test I used within the JS console.
// :visited is no longer detectable by getComputedStyle.
function getLinkColor(url) {
var a = document.createElement('a');
a.href = a.textContent = url;
document.body.appendChild(a);
return document.defaultView.getComputedStyle(a, null).color;
}
getLinkColor('http://stackoverflow.com/questions/5394099/detect-visited-link-in-chrome');
getLinkColor('http://stackoverflow.com/some-fake-path');
Run Code Online (Sandbox Code Playgroud)
对于Chrome扩展程序,如果您要检测用户是否访问过网址,我认为您必须请求"history"权限并致电chrome.history.getVisits.
| 归档时间: |
|
| 查看次数: |
6870 次 |
| 最近记录: |