Ver Mensaje Individual
  #20 (permalink)  
Antiguo 24/04/2008, 14:23
ssclamp
 
Fecha de Ingreso: octubre-2004
Mensajes: 289
Antigüedad: 19 años, 6 meses
Puntos: 10
Re: Mostrar un .html dentro de una etiqueta DIV

Hola daPhyre

Seguro que estoy haciendo algo mal, pero no me funciona ni offline ni online.

Este es el html
Código:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Prueba</title>
<script src="ajax.js" type="text/javascript"></script>
</head>

<body>

<p><a href="loadurl('pagina1.html', 'main')">Cargar página 1</a></p>
<p><a href="loadurl('pagina2.html', 'main')">Cargar página 2</a></p>



<div align="center">
	<div id="main" style="border:1px solid #C0C0C0; width: 500px; height: 400px">
		Espere mientras se carga el contenido. Si la página tarda e cargar, asegurate de tener JavaScript activado.
	</div>
</div>

</body>

</html>
Y este es el javascript:

Código:
function loadurl(url, id){
	var pagecnx = createXMLHttpRequest();
	pagecnx.onreadystatechange=function()
	{
		setpage(pagecnx, id)
	}
	pagecnx.open('GET', url, true)
	pagecnx.send(null)
}

function setpage(pagecnx, id){
	if (pagecnx.readyState == 4 && (pagecnx.status==200 || window.location.href.indexOf("http")==-1))
	document.getElementById(id).innerHTML=pagecnx.responseText;
}

function createXMLHttpRequest() {
	var xmlHttp=null;
	if (window.ActiveXObject) 
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	else 
		if (window.XMLHttpRequest) 
			xmlHttp = new XMLHttpRequest();
	return xmlHttp;
}
También tengo dos html llamados pagina1.html y pagina2.html que son los que se deberían cargar en el div, pero nada de nada... por favor podrías decirme que es lo que está mal.

Gracias