You should add in some checks, but this is how you would check for a hash.
if(window.location.hash) {
section=window.location.hash;
$(section).toggle();
}
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Micky Hulse
Sent: Tuesday, April 21, 2009 3:47 PM
To: jQuery (English)
Subject: [jQuery] "Hash-aware" script?
Hi,
First, my code:
========
...
if ($alt_nav_ul.length > 0) {
$alt_nav_ul.append('<li><a href="#"
class="folioLink">Portfolio</a></
li>');
$('a.folioLink').click(function() {
this.blur();
$folio = $('#folio').toggle();
return false;
});
} // $alt_nav_ul
...
========
What would be the best way for me to also look at the uri hash?
I would like #folio div to show if there is a hash in the uri:
<http://www.site.com#portfolio>
But I also want the href to handle show/hide of the #folio div.
Not looking for the exact code... Just kinda curious as to the best
approach to handling the hash -- I have never used a hash in my jquery
scripts before. :)
Any tips ya'll can send my way would be spectacular!
Many thanks in advance!
Cheers,
M