If URL contains anything, then fire a Javascript function
<p>Basically, if the URL/<code>window.location</code> contains absolutely any variable whatsoever (past domain.com/, of course), I'd like javascript to execute something. </p>

<p>Currently, I have the following jQuery code which only executes when <code>window.location</code> contains the exact wording "#hash", but as stated before I'd like to expand the functionality for all variables.</p>

<p><strong>Edit:</strong> Sorry, to clarify, by variable I mean any one of the following examples:</p>

<ul>
<li>domain.com/<strong>#hash</strong></li>
<li>domain.com/<strong>#hash2</strong></li>
<li>domain.com/<strong>sub/folder</strong></li>
<li>domain.com/<strong>textwithoutahash</strong></li>
</ul>

<p><em>Also, if someone knows how to do this in basic Javascript and without the need for the jQuery library, that would be an added bonus!</em></p>

<pre><code>$(function() {
    if ( window.location.href.indexOf('#hash') &gt; -1 ) {
        myfunctionhere;
    }
});
</code></pre>
