Lo que yo hice fue esto
Código Javascript
:
Ver original$(document).ready(function() {
if (typeof window.history.pushState == 'function') {
pushstate();
}else{
check(); hash();
}
});
// AJAX mágico que cambia la url;
function ajaxMagic(i,o){
var ajax = new XMLHttp();
with(ajax){
open("POST",i,true);
setRequestHeader("Content-type","application/x-www-for-urlencoded");
send(null);
onreadystatechange = function(){
if((readyState == 4) && (status == 200)){
respF = responseText;
if(respF != ""){
document.getElementById(o).innerHTML = respF;
}
}
}
}
}
function check(){
var direccion = ""+window.location+"";
var nombre = direccion.split("#!");
if(nombre.length > 1){
var url = nombre[1];
alert(url);
}
}
function pushstate(){
var links = $("a");
links.live('click', function(event) {
var divToChg = $(this).attr('ejemplo'); //este atributo no es valido en el TAG A pero lo creo igual
var url = $(this).attr('href');
history.pushState({
path: url
}, url, url);
ajaxMagic(url,divToChg)
return false;
});
$(window).bind('popstate', function(event) {
var state = event.originalEvent.state;
if (state) {
alert(state.path);
}
});
}
function hash(){
$(window).bind("hashchange",function(){
var hash = ""+window.location.hash+"";
hash = hash.replace("#!","")
if(hash != ""){
alert(hash);
}
});
$("a").bind('click', function(e) {
e.preventDefault();
var url = $(this).attr('href');
window.location.hash = "#!"+url;
return false
});
}
y en el tag <a> tendría que ser así
Código HTML:
Ver original<a href='loquesea.php' ejemplo='divDondeSeMostraraElResultado'>prueba
</a>