使用CSS访问的属性将href设置为文件 [英] Using CSS visited property for href to a file
本文介绍了使用CSS访问的属性将href设置为文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个锚定标记的HTML,一个到文件,一个到Google
I have this HTML of 2 anchor tags, one to a file and one to google
<a href="http://example.com/files/foobar.csv">
http://example.com/files/foobar.csv
</a>
<a href="http://google.com">
Google
</a>
我也有这个CSS可以使访问的定位标记变成红色。
I also have this CSS to make visited anchor tags red.
a:visited {
color: #ff0000;
}
当我单击google链接时,该链接会按预期变成红色,因为我
When I click on the google link, the link turns red as expected because I have visited it.
但是,当我单击文件时,链接不会变成红色。
When I click on the file however, the link does not turn red.
我如何让被访问的属性使用带有href的文件的锚标记
推荐答案
能否尝试直接在浏览器历史记录中插入URL。
Could you try to insert the URL directly in Browser History.
您可以执行以下操作:
HTML:
$(".file-link").click( function () {
$(this).attr("href");
var stateObj = { foo: "bar" };
window.history.pushState({ title: "Services" }, "foobar.csv", $(this).attr("href"));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#/files/foobar.csv" class="file-link">
http://example.com/files/foobar.csv
</a>
<a href="http://google.com">
Google
</a>
这篇关于使用CSS访问的属性将href设置为文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文