如何制作HTML反向链接? [英] How to make an HTML back link?

查看:127
本文介绍了如何制作HTML反向链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建链接到上一个网页的< a> 标记的最简单方法是什么?基本上是一个模拟的后退按钮,但是一个实际的超链接。仅限客户端技术。

编辑

寻找可显示网址的解决方案您将在悬停时点击的页面,就像普通的静态超链接一样。我不希望用户在超链接上悬停时查看 history.go(-1)。目前为止我发现的最好的是:



< script> document.write('< a href =''+ document.referrer +'>返回< / a>');< / script>

document.referrer 可靠吗?跨浏览器安全?我很乐意接受更好的答案。

解决方案

这个解决方案的好处是显示链接到因为大多数浏览器默认使用,而不是 history.go(-1)或类似的:

 <脚本> 
document.write('< a href ='+ document.referrer +'>返回< / a>');
< / script>


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.

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>

Is document.referrer reliable? Cross-browser safe? I'll be happy to accept a better answer.

解决方案

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屋!

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