Reputation: 627
I am using location.replace
to reload a page that uses GET variables for a success message.
My problem is, if the URL in the location.replace
is exactly the same the page does not reload. I know that if I can use a condition and use location.reload()
this will answer my question by I do not know how to use an IF statement on a location.replace
, or any other way this could be done.
So when calling the location.replace('?success=1');
whilst ?success=1
is already in the URL the page does not reload.
Could anyone shed some light on this?
Thanks
Upvotes: 2
Views: 1987
Reputation: 31920
if(window.location.href.match(/[?]success=1/))
window.location.reload();
else
window.location.replace('?success=1')
Upvotes: 2