Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/02/2010, 03:45
layker
 
Fecha de Ingreso: noviembre-2007
Mensajes: 264
Antigüedad: 16 años, 5 meses
Puntos: 0
Cargar div al actualizar la url

Hola, soy nuevo en ajax, he hecho el siguiente script para mi pagina, m gustaria que se pudiera navegar con la url pero no se como hacerlo, tipo: index.php#1.php fuese a la pagina 1.php o algo asi... alguien puede ayudarme?? un saludo. gracias
Cita:
<html>

<head>
<script language="JavaScript">
function Ajax(){
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(E) {
xmlhttp = false;
}
}
if(!xmlhttp && typeof XMLHttpRequest!="undefined"){
xmlhttp = new XMLHttpRequest();
}
return xmlhttp
}

function navegar(url,destino){
contenedor=document.getElementById(destino);
ajax=Ajax();
ajax.open("GET",url,true);
ajax.onreadystatechange=function(){
if(ajax.readyState==1){
contenedor.className="preloader";
} else if(ajax.readyState==4){
if(ajax.status==200){
contenedor.className='';
contenedor.innerHTML=ajax.responseText;
} else if(ajax.status==404){
navegar("404.php",destino);
} else {
contenedor.className='';
contenedor.innerHTML="Error: ".ajax.status;
}
}
}
ajax.send(null);
}
</script>
<style>
.preloader{
background-image:url('loading.gif');
background-repeat:no-repeat;
background-position:center center;
}
</style>
<title>Ejemplo Ajax</title>
</head>

<body>

<div>
<a href="#" onclick="navegar('1.php','contenido')">Pagina 1</a> |
<a href="#" onclick="navegar('2.php','contenido')">Pagina 2</a> |
<a href="#" onclick="navegar('3.php','contenido')">Pagina 3</a> |
<a href="#" onclick="navegar('4.php','contenido')">Pagina 4</a>
</div>
<div id="contenido" style="border:1px solid #000; width:400px; height:300px; overflow:scroll;"></div>

</body>

</html>