Link to reload current page

One way using JavaScript:

<a href="javascript:window.location.reload(true)">Reload</a>

None of the other answers will preseve any querystring values. Try

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

Admittedly this does involve javascript but, unless your users have script disabled, this is pretty straightforward.


I have been using:

<a href=".">link</a>

Have yet to find a case and/or browser where it does not work as intended.

Period means the current path. You can also use .. to refer to the folder above the current path, for instance, if you have this file structure:

page1.html
folder1
    page2.html

You can then in page2.html write:

<a href="../page1.html">link to page 1</a>

EDIT:

I'm not sure if the behaviour has changed or if it was always like this, but Chrome (and maybe others) will treat periods as described above as regarding directories, not files. This means that if you are at http://example.com/foo/bar.html you are really in the directory /foo/ and a href value of . in bar.html will refer to /foo/ rather than bar.html

Think of it as navigating the file system in a terminal; you can never cd into a file :)

EDIT 2:

It seems like the behaviour of using href="." is not as predictable anymore, both Firefox and Chrome might have changed how they handle these. I wouldn't rely entirely on my original answer, but rather try both the empty string and the period in different browsers for your specific use and make sure you get the desired behaviour.


You could do this: <a href="">This page</a>

but I don't think it preserves GET and POST data.

Tags:

Html

Hyperlink