title: How can i restrict page loading on reload option (browser)?
body: <p>i have a jsp page and i want to prevent it from reloading, if a user click on refresh then a dialogue box must be shown and ask for Confirm/Stay here. if user click on confirm the form must be submitted otherwise the page shouldn't refresh.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          window.onbeforeunload = function(evt) {
              var message = 'Are you sure you want to leave?';
              if (evt) {
                   document.forms["myForm"].submit();
             }
              else {
  
              }
              return message;
          }
  &lt;/script&gt;
  &lt;form action="SubmitExam.jsp" method="post" id="myForm"&gt; My Code&lt;/form&gt;
  </code></pre>