All right?
Next, I'm making a site with AJAX
navigation so you do not have to load the site every time you go to a page. Home, news, contact, etc ..
I managed to make the site, update the url, return button, everything right ..
However I have the following problem
Share / Refresh:
When I refresh the page or try to share the link with someone else, it does not load the site correctly. You are only opening the section of that particular page. Eg: If I want to share the
site.com.br/sobre.php
link it only opens the text of that page. The header, menu, footer do not appear. css
also comes unconfigured.
If it is the first load of the site, it does not have any problem .. But if you give refresh or share the link with friend, this problem already happens.
Note: I want to keep this type of navigation by the speed I got on the site.
This is the code I'm using:
$(document).ready(function() {
var content = $('#site'),
firstLink = $(".navbar li:first-child a").attr("href"),
navLink = $(".navbar li a");
content.load(firstLink);
navLink.on("click", function(event){
event.preventDefault();
event.stopImmediatePropagation();
var newLink = $(this).attr("href");
History.pushState(null, null, newLink);
$(".active").removeClass("active");
$(this).addClass("active");
content.load(newLink, function () {
FB.XFBML.parse();
});
});
History.Adapter.bind(window, "statechange", function() {
$(".active").removeClass("active");
$("a[href='" + History.getState().title + "']").addClass("active");
content.load(document.location.href);
});
});
And this is my menu:
<nav class="navbar">
<div class="container">
<ul>
<li><a class="active" href="/content/home.php">Inicio</a></li>
<li><a href="/content/servicos.php">Serviços</a></li>
<li><a href="/content/advogados.php">Advogados</a></li>
<li><a href="/content/escritorio.php">Escritório</a></li>
<li><a href="/content/noticias.php">Notícias</a></li>
<li><a href="/content/contato.php">Contato</a></li>
</ul>
</div>
</nav>
I think that would be it. If anyone can help me, I would appreciate it!