2

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

2
  • 2
    In which browser are you experiencing the issue? The following works fine in Firefox 14/Chrome 20: location.replace(location.href); (via console). The only case where the page is not refreshed is when the URL contains a URL fragment (#). Commented Jul 25, 2012 at 10:20
  • Hi, Yes I am also using a # in the URL to anchor the page Commented Jul 25, 2012 at 11:17

1 Answer 1

2
 if(window.location.href.match(/[?]success=1/))
    window.location.reload();
    else
    window.location.replace('?success=1')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.