javascript indexOf check in if statement
<p>Having some difficulty getting this code to work. Essentially, I want to check if the referring url is coming from the /mobile directory and if not and the screen is a mobile device I want to redirect to the mobile site.</p>

<pre><code>&lt;script type="text/javascript"&gt;
if(window.location.href.indexOf("document.write(document.referrer)") &gt; -1 &amp;&amp;
    screen.width &lt;= 699) {
    document.location = "/mobile/mobile_home.asp";
}

&lt;/script&gt;
</code></pre>

<p>The code is currently placed in the head of the main home.asp.</p>