Reputation:
I need to redirect user to the same url
of the page.
I know that window.location.href = 'custom_url';
will redirect to a custom_url
.
But I need to redirect him, to the same page that he's already in.
So how to do that with jQuery?
Upvotes: 0
Views: 229
Reputation: 693
the thing you could do is using
window.location.href = window.location.href;
it may take some time more than usual to read and change the href.
you can also use
location.replace(window.location.href);
using this, when you check your history, you will not see the site reloaded many times (I am using chrome).
and you can also use
location.assign("/");
.
Upvotes: 0
Reputation: 9923
So you need to refresh current page:
location.reload();
console.log("loaded");
<button onclick="location.reload();">Refresh Page </button>
Or by click via jQuery:
$('#something').click(function() {
location.reload();
});
Upvotes: 1