I can see a very complex way to do this by using the server to create content for you an getting it to the page in bits ore as a whole block.
I started trying this out the other day for a very simple client project, just creating something simple. There reson I'm doing it this way is to be able to create animation to change content.
This is my idea;
var href = window.location.href;
This will get the whole href from the address bar.
href = href.split("#/");
this can also bee # to split from an
has tag
item = href[1].split("/");
this can be anything you like to use to split each paremeter item.
lastitem = item[item.length-1]
This will add the last item of the array to an var. At this time its the only thing I need to find the correct page with the content I want.
This way I have the link in two parts, the first is the href after the hash tag, the last one, the "item", is each end link.
So there is just one index file, everything else is added into the content area with an jquery ajax url. At the start I check what the link is and find. Each content is just in another php file. But jquery can just as well get an html file an add its content anywhere you want with ajax url.
When the document is ready I check what the last item in the parameter (after /) is. I then have a php file with the same name, I find it and add it the the content area.
$.ajax({
url: lastitem'.php',
success: function(data) {
$('.content').html(data);
}
});
The links will then use a jquery .click(). If there is a site called "about" the the href of that link can be <a href="#/about">About us</a>
. This will then ofcorse add this to the end of the url in the address bar.
The click event can than be like this
$("a").click(function() {
var href = $(this).attr(href);
href = href.split(#/);
href = href[href.length-1];
$.ajax({
url: href'.php',
success: function(data) {
$('.content').html(data);
}
});
});
This is just a quick simple idea that I'm going to try out.