Get current pathname using JavaScript
<p>I'm using the following JavaScript to get the pathname to show a link is selected:</p>

<pre><code>var pathname = window.location.pathname;

    $(document).ready(function ()
    {

        $('ul#ui-ajax-tabs li a').each(function()
        {
            if ($(this).attr('href') == pathname)
            {
                $(this).parents('li').addClass('selected');
            }
        });
    });
</code></pre>

<p>However it has problems if that URL has extra parameters such as <code>/</code> on the end of the url or additional parameters (see examples below) Is it possible to check if the link matches part of the url so for example:</p>

<p>The Link is: <code>/Organisations/Journal/</code></p>

<p>And the Current page is: <code>/Organisations/Journal/Edit/21</code></p>

<p>This would class as being selected as it matches part of the url!</p>
