title: Confirm box before closing a tab
body: <p>I want to have a confirm box when user tries to close the window.</p>
  
  <pre class="lang-js prettyprint-override"><code>window.onbeforeunload = function (evt) {
      var message = 'Are you sure you want to leave, cause there are some unsaved changes?';
      if (typeof evt == 'undefined') {
          evt = window.event;
      }
      if (evt) {
          evt.returnValue = message;
      }
  
      return message;
  }
  </code></pre>
  
  <p>The thing is I want to check a variables value</p>
  
  <pre class="lang-js prettyprint-override"><code>var sncro = 1;
  </code></pre>
  
  <p>If its value is not equal to one then this confirmation box should be there, else no need to have a confirmation. I'm not able to figure this. Its so silly but I request anybody can have a look on the code.</p>