title: Change the get URL parameter on page refresh
body: <p>I have a form in a popup. User fills the details and submits the form. On form submission, the popup is closed and the user is redirected to the homepage. On submission, a message is displayed on the home screen (whether form submission is success or not). This is done by adding a parameter in the home page url. </p>
  
  <p>When user opens the site, the url will be <code>..../home</code>. And the user clicks on the popup button and submitting a form.</p>
  
  <p>On success, the url will be redirected to <code>..../home?error=0</code></p>
  
  <p>On Failure, the url will be redirected to <code>..../home?error=1</code></p>
  
  <p>Based on the error flag value, i display the message on home page.</p>
  
  <p>After this step, if user refreshes the home page, he still gets the form submission message because the error flag is present in the url. But after refresh, i dont want to display the message on home page.</p>
  
  <p>So, i tried to remove/set the error flag on page refresh using the following code.</p>
  
  <pre><code>&gt; $(window).unload(function() {
  &gt;      var currentURL = window.location.href;
  &gt;      var index = currentURL.indexOf("?error=");
  &gt;      if(index &gt; -1) {
  &gt;          window.location.href = currentURL.substring(0, index);
  &gt;      } });
  </code></pre>
  
  <p>It works well in Firefox but not in chrome. Not tested in other browsers. But jQuery unload has been deprecated in 1.8.</p>
  
  <p>How to remove/set the error flag on page refresh? Or is there any other method for not to display the message on home page after page refresh. The solution should work in all major browsers (IE, chrome, firefox. opera, safari)</p>
  
  <p>Note: This is a continuation of <a href="https://stackoverflow.com/questions/26085609/change-the-url-on-page-refresh">Change the URL on page refresh</a></p>
  
  <p>Thanks for your help!</p>