Foros del Web » Programando para Internet » Javascript »

script para controlar el scroll?

Estas en el tema de script para controlar el scroll? en el foro de Javascript en Foros del Web. hola buenas tardes estoy haciendo un chat con AJAX PHP y Jquery pero tengo un problema cuando se insertan bastantes mensages aparece un scroll y ...
  #1 (permalink)  
Antiguo 18/08/2011, 14:10
Avatar de shiriutoon  
Fecha de Ingreso: agosto-2011
Ubicación: Celaya GTO
Mensajes: 34
Antigüedad: 12 años, 8 meses
Puntos: 4
Pregunta script para controlar el scroll?

hola buenas tardes estoy haciendo un chat con AJAX PHP y Jquery pero tengo un problema cuando se insertan bastantes mensages aparece un scroll y para poder ver el mensage tengo que bajar el scroll y me gustaria saber si hay alguna forma de mantener el scroll abajo y cuando quiera ver los mensajes anteriores poder subirlo ??
  #2 (permalink)  
Antiguo 18/08/2011, 15:07
Avatar de Heiroon  
Fecha de Ingreso: junio-2010
Ubicación: Caracas, Venezuela - Por ahora...
Mensajes: 495
Antigüedad: 13 años, 10 meses
Puntos: 63
Desacuerdo Respuesta: script para controlar el scroll?

usa un ancla al final de la pagina y cada vez que recargue la enfocas y listo...

<div id=""></div>


el_archivo_que_tu_llamas_con_ajax.php#ancla

y con eso deberia de ser suficiente...
__________________
Gmail : [email protected]
Twitter: @heiroon

I'm back!
  #3 (permalink)  
Antiguo 19/08/2011, 09:01
Avatar de shiriutoon  
Fecha de Ingreso: agosto-2011
Ubicación: Celaya GTO
Mensajes: 34
Antigüedad: 12 años, 8 meses
Puntos: 4
Respuesta: script para controlar el scroll?

bueno alguna otra idea usando javascript esa solución que me diste ya lo había intentado y no funciona gracias por contestar
  #4 (permalink)  
Antiguo 19/08/2011, 10:28
Avatar de Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 19 años, 10 meses
Puntos: 834
Respuesta: script para controlar el scroll?

Fijate así:
Código PHP:
<!DOCTYPE HTML>
<
html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title></title>
<
style>
#pp{ width:200px; height:300px; border:1px solid #000; overflow:auto;}
</style>
<
script>
var 
ns={nop:0};
function 
bajar(){
    if(!
ns.nop)
        
document.getElementById('pp').scrollTop=document.getElementById('pp').scrollHeight;
    
setTimeout(bajar,10);
}
function 
isOver(){
    
ns.nop=1;    
}
function 
isOut(){
    
ns.nop=0;
}
onload=function(){
    
document.getElementById('pp').onmouseover=isOver;
    
document.getElementById('pp').onmouseout=isOut;
    
bajar();
};
</script>
</head>

<body>
<div id="pp">You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man.You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man.You think water moves fast? You should see ice. It moves like it has a mind. Like it knows it killed the world once and got a taste for murder. After the avalanche, it took us a week to climb out. Now, I don't know exactly when we turned on each other, but I know that seven of us survived the slide... and only five made it out. Now we took an oath, that I'm breaking now. We said we'd say it was the snow that killed the other two, but it wasn't. Nature is lethal but it doesn't hold a candle to man.</div>
</body>
</html> 
  #5 (permalink)  
Antiguo 19/08/2011, 11:13
Avatar de shiriutoon  
Fecha de Ingreso: agosto-2011
Ubicación: Celaya GTO
Mensajes: 34
Antigüedad: 12 años, 8 meses
Puntos: 4
Respuesta: script para controlar el scroll?

Muchas grasias Panino5001 me a funcionado perfecto.

Etiquetas: javascript-function
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 2 personas




La zona horaria es GMT -6. Ahora son las 15:41.