title: How to know whether the mouse is inside the window?
body: <p>I can't seem to find the answer.</p>
  
  <p>I have a <code>mouseleave</code> event, in which I want to check, when the event fired, whether the mouse is currently inside the window or not (if not, it can be the tab bar of the browser, back button, etc).</p>
  
  <pre><code>    var cursorInPage = false;
  $(window).on('mouseout', function() {
      cursorInPage = false;
  });
  $(window).on('mouseover', function() {
      cursorInPage = true;
  });
  $('#some_element').on("mouseleave",function(){
    if(cursorInPage === true){
       //Code here runs despite mouse not being inside window
      }
   });
  </code></pre>
  
  <p>Can I bind to a window <code>mouseleave</code> event? If you leave the outside scope of the document/window, does such an event fire? The above code has a problem since i believe the mouseleave of the element fires before the window</p>