title: window.onbeforeunload executed on page refresh instead of on page close
body: <p>I'm using <code>window.onbeforeunload</code> to pop up a confirm dialog when a close event occurs, but the confirm dialog appears on page refresh and doesn't execute on page close.</p>
  
  <p>Here's the JavaScript code:</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
      window.onbeforeunload = confirmWinClose();
      function confirmWinClose() {
          var confirmClose = confirm('Close?');
          return confirmClose;
      }    
  &lt;/script&gt;
  </code></pre>
  
  <p>I tried it on Chrome, Firefox and Internet Explorer.</p>