JS/Jquery way to determine if the user entered page from another site
<p>I am attempting to write a script that would launch a modal if the user enters a page from any external link. I am assuming the document.referrer is the way to do it, but not familiar enough with JS as to how to implement it in an "if" conditional. Any suggestions are appreciated.</p>

<p>I'm assuming it would look something like this?</p>

<pre><code>if (document.referrer !== window.location.hostname) {
  // do something
}
</code></pre>