title: message when move from page to another page
body: <p>I want when i enter information into a form than i click to a hyperlink to go to another page without submit the form a message appear are you sure you want to move to another page if the user click yes he go to another page if he click no he will stay in the same page where the form exist.</p>
  
  <p>And if the user go the page form and didn't enter any information in the field and click to move to another page the message didn't appear.</p>
  
  <pre><code> var formSubmitting = false;
  var setFormSubmitting = function() { formSubmitting = true; };
  
  window.onload = function() {
      window.addEventListener("beforeunload", function (e) {
          if (formSubmitting) {
              return undefined;
          }
  
          var confirmationMessage = 'It looks like you have been editing something. '
                                  + 'If you leave before saving, your changes will be lost.';
  
          (e || window.event).returnValue = confirmationMessage; //Gecko + IE
          return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
      });
  };
  </code></pre>
  
  <p>This code work if i enter information or not How can edit the code to when i didn't enter information the message don't appear.?</p>