是否有可能有一个正常的链接指向当前位置?

我目前找到了2个解决方案,但其中一个包括JavaScript,在另一个你必须知道页面的绝对路径:

<a href="#" onclick="window.location.reload(true);">1</a>
<a href="/foobar/">2</a>
<a href="#">3 (of course not working)</a>

有没有办法做到这一点,而不使用JavaScript或知道绝对路径?


当前回答

还有一个解决方案

<a href="javascript:history.go(0)">Reload</a>

其他回答

其他答案都不会保留任何查询字符串值。试一试

<a href="javascript:window.location.href=window.location.href">

不可否认,这涉及到javascript,但除非你的用户禁用了脚本,这是相当简单的。

<a href="/">Same domain, just like refresh</a>

似乎只有当你的网站是index.html, index.htm或index.php(任何默认页面)。

但似乎。是同样的东西,更容易被接受吗

<a href=".">Same domain, just like refresh, (more used)</a>

两者工作完美的Chrome浏览器时,域名都是http://和https://

如果你不关心保存查询字符串值,那么一个简单的选择是:

<a href > Link </a>

还有一个解决方案

<a href="javascript:history.go(0)">Reload</a>

你可以这样做:<a href=""> this page</a> .

但我认为它不会保留GET和POST数据。