title: My page goes to the onclick event before submit
body: <p>I have used submit and added an onclick event to it and I want to call the controller method save for it, and after that I want to redirect my page to another method of the controller for that I have used onclick where I have used <code>opener.href = ""</code>. My problem is that sometimes it goes to the save page but oftenly it goes to the onclick event first. I have searched it on google and all the methods tell me to the way I did but something is not right. Please help me.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;input id="m_bs_btnNext" type="submit" value="Save" onclick="closeWindow();" /&gt;
  </code></pre>
  
  <p>and the onclick function is:</p>
  
  <pre><code>function closeWindow() {
          window.opener.location.reload();
          window.opener.location.href = "ViewDesign";
          setTimeout("window.close()", 800);
      }
  </code></pre>