Ver Mensaje Individual
  #7 (permalink)  
Antiguo 15/04/2009, 12:06
Zack78
(Desactivado)
 
Fecha de Ingreso: enero-2008
Mensajes: 272
Antigüedad: 16 años, 3 meses
Puntos: 1
Respuesta: Controlar scroll en div

Cita:
Iniciado por Panino5001 Ver Mensaje
A ver si te sirve:
Código PHP:
<!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>Documento sin t&iacute;tulo</title>
<
script>
function 
ver(e,m){
    var 
t=e.keyCode || e.wich;
    if(
t==13){
       
agregar(m);
        return 
false;
    }
    return 
true;
}
function 
agregar(m){
    
document.getElementById('chat').innerHTML+='<br />'+m;
    
document.forms[0].textarea.value='';
}


onload=function(){
    
setInterval(function(){document.getElementById('chat').scrollTop=document.getElementById('chat').scrollHeight},30);
}
</script>
</head>

<body>
<div id="chat" style="width:400px; height:300px; overflow:auto; border:1px solid #000"></div>
<form id="form1" name="form1" method="post" action="">
  <textarea name="textarea" cols="60" rows="3" onkeypress="return ver(event,this.value)"></textarea>
</form>
</body>
</html> 

Gracias por reponder y por el script

me funciono excelente como queria.

Pero hay un problema, cuando quiero desplazar el scroll para ver los mensajes anteriores no me permite desplazar, siempre se mantiene abajo al final de la conversación

por favor me podes decir como solocionar este problema te agradesco de antemano

muchas gracias