title: javascript window mouseout event issue when mouse over on select/alertbox
body: <p>I have a requirement, when user movesout of the browser window, I need to display a Exit PopUp. It was fine in Chrome and Mozilla. The problem was with the devil IE only. There is a registration form in the Page. </p>
  
  <p>So in IE Below are the two issues I'm facing not able to figure it out.</p>
  
  <ol>
  <li><p>when user trying to select the options of the select box this mouseout event triggering and Exit PopUp displaying</p></li>
  <li><p>There is terms and conditions checkbox which will show you alert without checking it when user try to submit. When I clicks OK button on alert box the mouseout event triggering and showing my Exit PopUp.</p></li>
  </ol>
  
  <p>How to avoid these two things. These issues are stopping the user from registering to our website.</p>
  
  <p>Below is my code</p>
  
  <pre><code>var mouseX = 0;
  var mouseY = 0;
  var mouseIsIn = true;
  window.addEventListener("mouseout", function(e){
      mouseX = e.pageX;
      mouseY = e.pageY;
      if ((mouseY &gt;= 0 &amp;&amp; mouseY &lt;= window.innerHeight) &amp;&amp; (mouseX &gt;= 0 &amp;&amp; mouseX &lt;= window.innerWidth))
          return;
  
      document.getElementById("exitPop").style.display = 'block';
      mouseIsIn = false;
  
  }, false);
  
  window.addEventListener("mouseover", function(e){
      if(mouseIsIn)
          return;
  
      mouseIsIn = true;
  },false);
  </code></pre>
  
  <p>What are the changes I need to do to overcome those 2 issues? </p>
  
  <p>jQuery solutions are also welcome.</p>
  
  <p><strong>UPDATE</strong>
  Somehow I managed to fix the Selectbox issue by adding the following code</p>
  
  <pre><code>window.onmouseout = function(e){
  inWin--;
  setTimeout(function(){
      if(isIEbrowser) {
              if (e.toElement == null &amp;&amp; e.relatedTarget == null)
                 inWin--;
  
              if (e.srcElement !== undefined &amp;&amp; e.srcElement.nodeName != undefined &amp;&amp; (e.srcElement.nodeName == 'SELECT' || e.srcElement.nodeName == 'OPTION'))
                  inWin=1;
          }
  
      if(inWin &lt;=0)
      {       
              document.getElementById("exitPop").style.display = 'block';
          }
  }, 100);}window.onmouseover = function(e){       inWin=1;}
  </code></pre>
  
  <p>But not able to fix the alertbox issue. Surprisingly this alertbox issue I'm facing both in IE and Firefox also.</p>