title: detect 404 error on page load
body: <p>I am embedding a google map in my website and sometimes google responds with a 404 error.  I know I should know this, but I can't remember and I cannot find it quickly.  None of the other 404 iframe related questions on this site were ever answered.</p>
  
  <p>How do I check if there is a 404 response in javascript?  I plan to call location.reload() when the response is 404.</p>
  
  <pre><code>&lt;iframe src="https://mapsengine.google.com/map/embed?mid=zGLD-nMIJQAg.k0gTyNlOPz_Q" width="640" height="480"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>The error code is: </p>
  
  <pre><code>GET https://khms0.googleapis.com/kh?v=159&amp;hl=en&amp;x=784456&amp;y=1636828&amp;z=22&amp;token=122715 404 (Not Found)
  </code></pre>
  
  <p>I tried this:  It didn't help.</p>
  
  <pre><code>var url = 'https://mapsengine.google.com/map/embed?mid=zGLD-nMIJQAg.k0gTyNlOPz_Q';
  if (url.statusCode === '404'){
      window.location.reload();
  }
  </code></pre>