HighDots Forums  

scroll bottom div

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss scroll bottom div in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alberto
 
Posts: n/a

Default scroll bottom div - 12-23-2007 , 02:52 AM






ciao,
ho questo codice in una chat ajax:

function saluta() {
if (ingresso.value!="") {
<& ajax.mhtml, comp=>'SELF:my_ajax_test',
position=>'bottom' &>
var objDiv = document.getElementById("testo");
// objDiv.scrollTop = objDiv.scrollHeight;
objDiv.scrollTop = objDiv.offsetHeight;
ingresso.value="";
// window.alert(objDiv.scrollHeight);



}
}

che mi da il seguente problema:
la scroll bar scrolla automaticamente quando ricevo i dati, ma va alla
penultima riga e non all'ultima.
Ho provato con i seguenti browser:

Osx: firefox, opera, camino, seamonkey, safari
Linux: konqueror, safari

il primo commento č una modifica che ho trovato su internet.
Il codice l'ho preso daqui:
http://radio.javaranch.com/pascarell...573598403.html
Grazie

Alberto

Reply With Quote
  #2  
Old   
Alberto
 
Posts: n/a

Default Re: scroll bottom div - 12-23-2007 , 03:26 AM






Aggiungo che la funzione viene inviata al browser cosė

function saluta() {
if (ingresso.value!="") {
new Ajax.Updater('testo', '/secret/mason/prototype/ajax.mhtml', {
insertion: Insertion.Bottom , parameters: '' + Form.serialize( xxx ) +
'&_comp=%2Fsecret%2Fmason%2Fprototype%2Ftest.mhtml %3Amy_ajax_test' } )
var objDiv = document.getElementById("testo");
// objDiv.scrollTop = objDiv.scrollHeight;
objDiv.scrollTop = objDiv.offsetHeight;
ingresso.value="";
// window.alert(objDiv.scrollHeight);



}
}

Alberto

Reply With Quote
  #3  
Old   
Alberto
 
Posts: n/a

Default Re: scroll bottom div - 12-24-2007 , 03:52 AM



Ho scoperto, sembra che il codice sia asincrono, lo scorrimento avviene
prima dell'aggiornamento della div.
Facendo eseguire lo scorrimento dopo 500 millisecondi funziona.

Alberto

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.