How do I get the referrer's domain/host name using javascript?
<p>I know I can get the host name of the current page, by simply doing:</p>

<pre><code>var myhostname = location.hostname;
</code></pre>

<p>But how do I get the host name of the referrer? I can get the referrer by</p>

<pre><code>var referrer = document.referrer;
</code></pre>

<p>but unfortunately there's no <code>document.referrer.hostname</code> available in javascript. Any ideas how I can get this value?</p>

<p>An example of where this is useful is if somebody clicks a link on google.com, I want to be able to retrieve google.com from the referrer (not the page and the query string).</p>
