I am trying to do something different without knowing if it is a good idea or not
I have a navigation menu as the following:
...
<li><a href = "#mhome">Home</a></li>
<li><a href = "#mfaq">FAQ</a></li>
<li><a href = "#mcontact">Contact</a></li>
...
I do not want to use a server-side scripting because it takes more time to make db connection and define some configuration, and not want to multiply the pages for each one. So I made a master page index.php
in body
section
there are two elements:
an h3
element to display the page title and a div
to display the content which is called from another html source.
...
<div class="container">
<h3 id="pageTitle"></h3>
<div id="pageContent"></div>
</div>
...
I am using jQuery's click event to load the page into the div
$(function() {
$("a[href^='#m']").click(
function() {
$("#pageTitle").text($(this).text());
$("#pageContent").load($(this).attr("href").substring(1) + ".html"); //removing # char.
});
});
It works fine. But when I press F5 it returns the initial state as normal. How can I load the current page by referencing the address bar (I can see eg. sitename/#mfaq
) when page is refreshed.
I think, first I need to detect if page is refreshing and load the corresponding html file in according to the #m****
on the addressbar.