title: Disable or hide are you sure you want to leave this page using javascript
body: <p>I have a Javascript code which redirect to another page if the button is click.</p>
  
  <p>The issue is I am getting the browser pop-up "Are you sure you to leave this page", which I don't want to see in my web page.
  I tried:</p>
  
  <pre><code>function onClick()
  {
    FormData(actionName);
  }
  
  function FormData(url)
  {
   var form = $('&lt;form action ="'+url+'" method="post" &gt; &lt;/form&gt;');
   $('body').append(form);
   form.submit();
  }
  </code></pre>
  
  <p><code>window.onbeforeunload = null;</code> and <code>window.unload = null;</code>
  but still I am seeing the same browser message.
  Please help me how to avoid.</p>