title: Some parts of Javascript not working in Chrome, but work perfectly in other browsers
body: <p>General information: I'm trying to create a popup modal window to verify customer zip codes - the website is only for people within a particular range of codes, so I just need it to pop up, take their input, and if they're eligible to shop, close, let them shop, and not show up again at least for the session, and if they aren't eligible, to redirect them to another website.</p>
  
  <p>I have it working perfectly in Firefox, Edge, and IE, but Chrome, while running most of it just fine, completely ignores other parts.  This is my first real attempt at doing anything with Javascript, so I'm hoping it's a simple answer.</p>
  
  <p>Another note: sorry about all the commented out lines, I've been trying to keep close track of where I've been so I can undo my changes more easily if necessary.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;!--START: ZipCheckModal--&gt;
  &lt;!-- Trigger/Open The Modal --&gt;
  &lt;!--&lt;button id="myBtn"&gt;Open Modal&lt;/button&gt;--&gt;
  
  &lt;!-- The Modal --&gt;
  &lt;div id="zipModal" class="zipmodal"&gt;
  
  &lt;!-- Modal content --&gt;
  &lt;div class="zipmodal-content"&gt;
  &lt;div class="zipmodal-header"&gt;
    &lt;span class="close"&gt;×&lt;/span&gt;
    &lt;h2&gt;Welcome to Nature's Warehouse Ohio!&lt;/h2&gt;
  &lt;/div&gt;
  &lt;div class="zipmodal-body"&gt;
    &lt;div class="overblur"&gt;
  &lt;div class="zipcheckarea" id="zipcheckarea"&gt;&lt;h1&gt;Check your zip code&lt;/h1&gt;&lt;br /&gt;&lt;p&gt;This site is for customers within our Ohio Local Delivery Zone.  Check to see if you're eligible!&lt;/p&gt;&lt;br /&gt;
  
  &lt;form class="zipbox"&gt;
    &lt;input type="number" id="custzip" placeholder="Your Zip" maxlength="5"/&gt;&lt;br /&gt;
  
    &lt;input type="submit" id="zipbtn" value="Check Zip" onclick="checkZip()" /&gt;&lt;br /&gt;
  
  &lt;/form&gt;&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>
  
  <p>Some Javascript that is inline, immediately beneath the above (at some point I couldn't get it to run in a separate file, so I just left it inline)</p>
  
  <pre><code>// Get the modal
  var zipmodal = document.getElementById('zipModal');
  
  // Get the button that opens the modal
  var btn = document.getElementById("myBtn");
  
  // Get the &lt;span&gt; element that closes the modal
  var span = document.getElementsByClassName("close")[0];
  
  // When the window opens, open the modal 
  //Add "if there is no cookie" here
  checkZipCookie();
  //window.onload = function() {
  //    zipmodal.style.display = "block";
  //}
  
  // When the user clicks on &lt;span&gt; (x), close the modal
  span.onclick = function() {
  zipmodal.style.display = "none";
  }
  
  // When the user clicks anywhere outside of the modal, close it
  //window.onclick = function(event) {
  //    if (event.target == zipmodal) {
  //        zipmodal.style.display = "none";
  //    }
  //}
  </code></pre>
  
  <p>And finally, the separate Javascript file:</p>
  
  <pre><code>function checkZip() {
  var custzip = document.getElementById("custzip").value;
  var ziparray = ["44606", "43803", "43804", "44608", "44610", "44611", "43805", "44612", "44613", "44617", "44618", "44622", "44624", "44627", "43824", "44628", "44633", "43828", "44636", "44637", "44638", "44647", "44654", "44659", "44660", "44661", "44662", "44666", "44667", "44676", "44677", "43840", "44680", "44681", "44687", "44689", "44690", "44691", "44697"];
  if (ziparray.indexOf(custzip) &gt; -1) {
  document.getElementById("zipcheckarea").innerHTML = "You qualify for same-day delivery!\nIn a moment you will be redirected to the home page."; 
  document.getElementById("zipcheckarea").className = "delaymsg";
  setTimeout(sendOH, 3000);
  } else {
  document.getElementById("zipcheckarea").innerHTML = "We're sorry, you don't qualify for same-day delivery.\nTry our regular website, where we offer FREE shipping on orders over $24.95!"; 
  document.getElementById("zipcheckarea").className = "delaymsg";
  setTimeout(sendNY, 4000);
  }
  }
  
  function sendOH() {
  setZipCookie("resident");
  zipmodal.style.display = "none";
  //window.location.href = "http://ohio.natureswarehouse.net";
  }
  function sendNY() {
  window.location.href = "http://natureswarehouse.net";
  }
  
  function setZipCookie(cname, cvalue, exdays) {
  var d = new Date();
  d.setTime(d.getTime() + (exdays*24*60*60*1000));
  var expires = "expires="+ d.toUTCString();
  document.cookie = cname + "=" + cvalue + "; " + expires;
  }
  
  function getZipCookie(cname) {
  var name = cname + "=";
  var ca = document.cookie.split(';');
  for(var i = 0; i &lt;ca.length; i++) {
      var c = ca[i];
      while (c.charAt(0)==' ') {
          c = c.substring(1);
      }
      if (c.indexOf(name) == 0) {
          return c.substring(name.length,c.length);
      }
  }
  return "";
  }
  
  function checkZipCookie() {
  var isCookie = getZipCookie("resident");
  if (isCookie != "") {
      //Show nothing, free to browse
  } else {
  //Run the modal window
  window.onload = function() {
    zipmodal.style.display="block";
  }
  }
  }
  </code></pre>
  
  <p>The problems I'm seeing are 1) Chrome doesn't follow the correct close modal/redirect, it just closes the modal window no matter what the input is, 2) ignores the timeouts before redirecting, and 3) doesn't set the cookie, so the modal keeps popping up every time.  I get the same issues messing with it in codepen (but only in Chrome), and it seems to run flawlessly in the other browsers.</p>
  
  <p>I'm not getting any errors in my console or anything, Chrome seems to think it's doing everything right.  If you want to check out the actual model, it's at ####.</p>