I am trying to develop a website and do a pretty standard thing that I see in common webpages. I have an index.html
page where I have the menu bar through which the user can navigate to other pages. Now, instead of opening separate pages, I am loading the contents of other pages in the <div id="content-wrapper"></div>
of the same index.html
page.
The script that allows me to do this is as shows below:
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
function getPage(url) {
$("#content-wrapper").load(url);
}
</script>'
and the navigation link looks like:
<a href="#" title="" class="active" onclick="getPage('./web/contact/contact.html');">Contact</a>
This is working fine, except since the contents are loaded in the index.html
site, the URL
in the address bar of the browser did not change. Hence, if I refresh the page, I am taken to the home page. So, the user will not be able to share any specific page using the URL
.
I tried to find ways people do it and found that mostly they use a form
element with post
method, but couldnt find a good tutorial to do this. (Possible duplicate question without satisfactory answer). Other answer I found is the use of jQuery Address plugin, but wasn't sure which one is better.
Any solution or guidance for this is much appreciated.