Link to home
Start Free TrialLog in
Avatar of kephillips
kephillips

asked on

auto scroll to bottom of page...

Hi experts.
I'm developing a simple little chat and would like the text to scroll to the bottom of the page. How would I do this???
thanks.
Avatar of archrajan
archrajan

<SCRIPT>
document.body.scrollTop = document.body.scrollHeight
</script>

I am not exactly sure what your asking for.

If you mean something like this


<html>
      <body>
            <form name="frmMain">
                  <input type="text" name="txtChatText" value="">
                  <input type="button" value="Chat" onclick="this.form.txtChatResults.value+=this.form.txtChatText.value;">
                  
                  <br>
                  <textarea name="txtChatResults" rows="10" cols="10"></textarea>
            </form>
      </body>
</html>


I am assuming this is a chat between two users, how are you getting the information from one client to the other?
Avatar of kephillips

ASKER

justinbillig,
I'm using mysql as a backend...
arch,
sorry no go..
doesn't do a thing...
i found what I was looking for guys,

<body onLoad="for (i=0;i<window.screen.availHeight;i++) {window.scroll(0,i); }">
thanks anyways!
Thanks for sharing the answer!
Good luck
Avatar of Michel Plungjan
That does not look right....

If you want the page to scroll to the bottom it is just luck chat window is smaller than the available height and it will stop at for example 600 pixel if that is the size of the window... unless you refresh the window and remove the text that is no longer visible



<body onLoad="window.scrollTo(0,9999999)">
will also work unless you chat for days
ASKER CERTIFIED SOLUTION
Avatar of ThaSmartUno
ThaSmartUno

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial