Building a site that uses AJAX to Asynchronously import content into it? You can take advantage of the URL hash value and some of the functionality it gives you.
This blog entry is an intro to this process, where we deal with adding the hash value into a URL.
First of all we will create a set of hyperlinks that are attached to a JQuery selector.
<li><a href="home.cfm" class="ajax-link" id="home">Home</a></li>
<li><a href="about.cfm" class="ajax-link" id="about">About</a></li>
<li><a href="buy.cfm" class="ajax-link" id="buy">Buy</a></li>
<li><a href="contact.cfm" class="ajax-link" id="contact">Contact</a></li>
Next we create a simple click function.
// click event listener
// get the id
var clickedLink = $(this).attr('id');
// push it into the url
location.hash = clickedLink;
// debugging alert
// stop the regular href
This picks up any link clicked on and gets the id attribute. Next we use location.hash to push the value into the URL. Note that it adds an actual # character to the start of the string.
Lastly it prevents the hyperlink click event from firing so that we don't actually move to the new page.
A short and simple script to add hashed values to a URL. There is a demo of this working here: http://www.mccran.co.uk/examples/jquery-url-hashes/