Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Encontrei uma solução boa para fazer voltar atras e à frente no navegador e para guardar nos favoritos as páginas carregadas por ajax.
Falta saber (ainda não testei) se as páginas ficam indexadas nos motores de busca.
JS's necessários: http://www.mikage.to/jquery/jquery_history.html
Solução:
Colocar isto entre <head></head>
<script type="text/javascript" src="jquery/jquery-1.1.1.js"></script><script type="text/javascript" src="jquery/jquery.history.js"></script><script type="text/javascript"> // PageLoad function // This function is called when: // 1. after calling $.historyInit(); // 2. after calling $.historyLoad(); // 3. after pushing "Go Back" button of a browser function pageload(hash) { // hash doesn't contain the first # character. if(hash) { // restore ajax loaded state $("#load").load(hash + ".html"); } else { // start page //$("#load").empty(); $('#load').load("home.html"); // abre a pagina home.html ao abrir o site } } $(document).ready(function(){ // Initialize history plugin. // The callback is called at once by present location.hash. $.historyInit(pageload); // set onlick event for buttons $("a[@rel='history']").click(function(){ // var hash = this.href; hash = hash.replace(/^.*#/, ''); // moves to a new page. // pageload is called at once. $.historyLoad(hash); return false; }); }); </script>Os links ficam assim:
<li><a href="#home" rel="history" title="Inicio">Inicio</a></li><li><a href="#empresa" rel="history" title="Empresa">Empresa</a></li><li><a href="#servicos" rel="history" title="Serviços">Serviços</a></li><li><a href="#localizacao" rel="history" title="Localização">Localização</a></li><li><a href="#contactos" rel="history" title="Contactos">Contactos</a></li>
Div onde vai abrir as páginas:
<div id="load"></div>
Alguma dúvida é só dizer.
Carregando comentários...