Thanks, I ended up using a switch:
var page = location.hash;
switch(page)
{
case "#networks":
showPlaces();
break;
case "#about":
showAbout();
break;
case "#contact":
showContact();
break;
default:
showPlaces();
}

Works great for me.

Thanks again,
Alex

-- Alex


On Fri, Dec 5, 2008 at 5:57 PM, Andy Matthews <[EMAIL PROTECTED]>wrote:

>  location.hash is a property, so you'd just get it's value then compare
> that. Something like this might work:
>
> // get the hash
> var page = location.hash;
> // show the correct page
> $('#' + page).show();
>
>
>
> andy matthews
>
>
>  ------------------------------
> *From:* jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Alex Hempton-Smith
> *Sent:* Friday, December 05, 2008 11:48 AM
> *To:* jquery-en@googlegroups.com
> *Subject:* [jQuery] Using "window.location.hash" for URLs without plugin
>
> Hi,
> I'm trying to use URL's such as 'mysite.com/#contact' that will show a
> certain div.
> I have my function written and working to show the div, currently being
> used as "$("#a.contact").click(showContact);"
>
> How would I use something like "window.location.hash" to fire off the
> function "showContact" for example, if the URL was /#contact?
>
> This would need to provide for about 3 pages, Home, About, Portfolio and
> Contact.
> I know there's a plugin for enabling use of the back button etc, but I'd
> rather something simple without having to load plugins.
>
> Many thanks,
> Alex
>

Reply via email to