Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/04/2008, 15:11
Avatar de hgp147
hgp147
 
Fecha de Ingreso: diciembre-2006
Ubicación: Buenos Aires, Argentina
Mensajes: 980
Antigüedad: 17 años, 3 meses
Puntos: 36
Re: ¿Como cambiar el contenido de un <div> al pinchar en un enlace?

Cita:
¿Se puede hacer?¿Como?
¿Con php, con javascript?
¿Que codigo y de que manera tendria que ponerlo?
Sí, se puede hacer. Así sería con AJAX:

PAGINA PRINCIPAL "ejemplo.php"

Código HTML:
<!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=utf-8" />
<title>Documento sin t&iacute;tulo</title>

<style type="text/css">
<!--
@import url("estilo1.css");
-->
</style>
<script>
function nuevoAjax(){

    var xmlhttp=false;
    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 Cargar(url){


var contenido = document.getElementById('contenido');
       
ajax=nuevoAjax(); 
ajax.open("GET", url,true); 
ajax.onreadystatechange=function(){

if(ajax2.readyState==4){

contenido.innerHTML=ajax.responseText;

}

}
        
ajax.send(null);



}
</script>
</head>

<body>
<div id="menu"><?php include("menu.php"); ?></div>
<div id="contenido"><?php include("contenido1.php"); ?></div>
</body>
</html> 

PAGINA menu "menu.php"

Código PHP:
<a href="#" onclick="Cargar('contenido1.php');">Link1</a><br />
<
a href="#" onclick="Cargar('contenido2.php');">Link2</a><br />
<
a href="#" onclick="Cargar('contenido3.php');">Link3</a><br /> 
__________________
Spread Firefox | Download Day 2008
¡Únete en nuestra misión para alcanzar el Record Guinness al software más descargado en 24 horas! http://www.spreadfirefox.com/es-ES/worldrecord/

Última edición por hgp147; 13/04/2008 a las 15:27