Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/03/2007, 13:16
Avatar de AlZuwaga
AlZuwaga
Colaborador
 
Fecha de Ingreso: febrero-2001
Ubicación: 34.517 S, 58.500 O
Mensajes: 14.550
Antigüedad: 23 años, 2 meses
Puntos: 535
Re: Recagar title sin regargar página

Yo había hecho algo así. Lo adapto a tu ejemplo:


Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>T&iacute;tulo original</title>
<script language="JavaScript" type="text/javascript">
function nuevoAjax()
{ 
	/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
	lo que se puede copiar tal como esta aqui */
	var xmlhttp=false; 
	try 
	{ 
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e)
	{ 
		try
		{ 
			// Creacion del objet AJAX para IE 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch(E) { xmlhttp=false; }
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 

	return xmlhttp; 
}


function actualizaTitle(enlace){
		ajax=nuevoAjax();
		ajax.open("GET", "title_exe.php?enlace="+enlace, true);
		ajax.onreadystatechange=function()
		{ 
			if (ajax.readyState==1)
			{
				document.title = "Cargando nuevo titulo";
			}
			if (ajax.readyState==4)
			{ 
				document.title = ajax.responseText;
			} 
		}
		ajax.send(null);
}
</script>

</head>

<body>
<ul>
  <li><a href="#" onclick="actualizaTitle('0')">Cambiar title a &quot;hola&quot;</a></li>
  <li><a href="#" onclick="actualizaTitle('1')">Cambiar title a &quot;adios&quot;</a></li>
  <li><a href="#" onclick="actualizaTitle('2')">Cambiar title a &quot;hasta&nbsp;luego&quot;</a></li>
</ul>
</body>
</html>

title_exe.php:
Código:
<?
if(isset($_GET['enlace'])){
	$enlace = $_GET['enlace'];
	switch($enlace){
		case 0:
			$titulo = "hola";
			break;
		case 1:
			$titulo = "adios";
			break;
		case 2:
			$titulo = "hasta luego";
			break;
		default:
			$titulo = "";
			break;
	}
	echo $titulo;
}
else{
	echo "No se ha especificado parámetro";
}
?>
__________________
...___...