Ver Mensaje Individual
  #23 (permalink)  
Antiguo 27/01/2012, 15:56
breaststroke
 
Fecha de Ingreso: octubre-2010
Mensajes: 189
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: Controlar scroll en div

Cita:
Iniciado por Panino5001 Ver Mensaje
Bueno, agregando un pequeño control que se active onmouseover y onmouseout creo que se soluciona:
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(){if(window.parar)return;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" onmouseover="parar=1" onmouseout="parar=0"></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> 
Muy buenas.
Yo estoy con el mismo problema pero no he conseguido solucionarlo. no consigo que la barra scroll no se quede fija abajo cuando quiero moverla.
Además de lo que habéis puesto he intentado lo siguiente:

Código Javascript:
Ver original
  1. // una función disparada con onkeyPress:
  2. ....
  3. ....
  4. //al final de la función:
  5. if(window.parar)return;
  6. var myCont = document.getElementById ("chata");
  7.             myCont.scrollLeft = 0;
  8.             myCont.scrollTop = 80000;
  9. }

Consigo tb que la barra permanezca abajo cuando hay mucho texto, pero como digo, no que la pueda mover al pulsar en ella.

agradecería cualquier ayuda.

Un saludo