如何制作 HTML 反向链接? [英] How to make an HTML back link?
问题描述
创建链接到上一个网页的 标签的最简单方法是什么?基本上是一个模拟的后退按钮,而是一个实际的超链接.请仅使用客户端技术.
What is the simplest way to create an <a>
tag that links to the previous web page? Basically a simulated back button, but an actual hyperlink. Client-side technologies only, please.
编辑
寻找能够在悬停时显示您将要点击的页面的 URL 的解决方案,就像一个普通的静态超链接.我不想让用户在将鼠标悬停在超链接上时查看 history.go(-1)
.迄今为止我发现的最好的是:
Edit
Looking for solutions that have the benefit of showing the URL of the page you're about to click on when hovering, like a normal, static hyperlink. I'd rather not have the user looking at history.go(-1)
when hovering on a hyperlink. Best I've found so far is:
<script>
document.write('<a href="' + document.referrer + '">Go Back</a>');
</script>
document.referrer
可靠吗?跨浏览器安全吗?我很乐意接受更好的答案.
Is document.referrer
reliable? Cross-browser safe? I'll be happy to accept a better answer.
推荐答案
这个解决方案的好处是在悬停时显示链接页面的 URL,就像大多数浏览器默认做的那样,而不是 history.go(-1)
或类似的:
This solution has the benefit of showing the URL of the linked-to page on hover, as most browsers do by default, instead of history.go(-1)
or similar:
<script>
document.write('<a href="' + document.referrer + '">Go Back</a>');
</script>
这篇关于如何制作 HTML 反向链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!