title: location.host vs location.hostname and cross-browser compatibility?
body: <p>Which one of these is the most effective vs checking if the user agent is accessing via the correct domain.</p>
  
  <p>We would like to show a small js based 'top bar' style warning if they are accessing the domain using some sort of web proxy (as it tends to break the js).</p>
  
  <p>We were thinking about using the following:</p>
  
  <pre><code>var r = /.*domain\.com$/;
  if (r.test(location.hostname)) {
      // showMessage ...
  }
  </code></pre>
  
  <p>That would take care of any subdomains we ever use.</p>
  
  <p>Which should we use host or hostname?</p>
  
  <p>In Firefox 5 and Chrome 12:</p>
  
  <pre><code>console.log(location.host);
  console.log(location.hostname);
  </code></pre>
  
  <p>.. shows the same for both.</p>
  
  <p>Is that because the port isn't actually in the address bar?</p>
  
  <p><a href="http://www.w3schools.com/jsref/obj_location.asp" rel="noreferrer">W3Schools</a> says host contains the port.</p>
  
  <p><strong>Should location.host/hostname be validated or can we be pretty certain in IE6+ and all the others it will exist?</strong></p>