html href force - Link to reload current page

9 Answers

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.

refresh php using

Is it possible to have a normal link pointing to the current location?

I have currently found 2 solutions, but one of them includes JavaScript and in the other you have to know the absolute path to the page:

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

Is there any way of doing this, without using JavaScript or knowing the absolute path?

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

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

<a href=".">refresh current page</a>

or if you want to pass parameters:

<a href=".?curreny='usd'">refresh current page</a>

<a href="/">Clicking me refreshes the page</a>

<a href="?">Click Me To Reload the page</a>

Completely idempotent url that preserves path, parameters, and anchor.

 <a href="javascript:"> click me </a>

it only uses a little tiny bit of JS.

EDIT: this does not reload the page. It is a link that does nothing.

I use JS to show only the div with a specific id in the tags page in a jekyll site. With a set of links in the same page, you show the corresponding element:

function hide_others() {
    selected = location.hash.slice(1);
    if (selected) {
        $('#' + selected).show();
    else {

links use links like:

<a href="javascript:window.location.href='/tags.html#{{ tag[0] }}-ref'; hide_others()">{{ tag[0] }}</a>

You can use a form to do a POST to the same URL.

 <form  method="POST" name="refresh" id="refresh">
 <input type="submit" value="Refresh" />

This gives you a button that refreshes the current page. It is a bit annoying because if the user presses the browser refresh button, they will get a do you want to resubmit the form message.

<a href="/home" target="_self">Reload the page</a>

If you are using php/smarty templates, u could do something like this:

<a href="{{$smarty.server.REQUEST_URI}}{if $smarty.server.REQUEST_URI|strstr:"?"}&{else}?{/if}newItem=1">Add New Item</a>