www.webdeveloper.com
Results 1 to 3 of 3

Thread: MSN-like scrolling?

  1. #1
    Join Date
    Feb 2011
    Posts
    7

    MSN-like scrolling?

    Hi,

    I have a fixed textarea which is being updated every second. (id is 'log')

    Now, I'm trying to get the scrollbar to act like msn (or cmd, for that matter)
    When the page is updated, and the scrollbar was already down, let the scrollbar go to the bottom. That's easy: "log.scrollTop = log.scrollHeight" every update.

    The big problem here, is that when the user scrolls up, in other words, isn't at the bottom, the scrollbar should not move. How would I do that?

    I'm allowed to use jQuery and Jscrollpane if needed.

    Thanks for the help!

  2. #2
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    code?

  3. #3
    Join Date
    Feb 2011
    Posts
    7
    Here you go:
    Code:
    				req.onreadystatechange=function() {
    					if ((req.readyState==4) && (req.status==200)) {
    					    var log = document.getElementById("log");
    						var txt = document.createTextNode(req.responseText);
    						log.appendChild(txt);
    						//log.insertBefore(txt, log.firstChild)
    						var idx = req.responseText.indexOf("\r");
    						var receivedLines = 0;
    						while (idx != -1) {
    							receivedLines++;
         						idx = req.responseText.indexOf("\r", idx + 1);
    						}
    						
    						browserLines = browserLines + receivedLines;
    						if (receivedLines >= 25) {
    							if ((scrollbarIsDown = true) && (scrollbarGoDown = true)) { //
    								log.scrollTop = log.scrollHeight;
    							}
    						    setTimeout("loadXMLDoc()", 100);
    						}
    						else {
    							if ((scrollbarIsDown = true) && (scrollbarGoDown = true)) { //
    								log.scrollTop = log.scrollHeight;
    							}
    						    setTimeout("loadXMLDoc()", 2000);
    						}
    					}
    				}
    				//req.open("POST","http://localhost/gateway?system",true);
    				req.open("POST","logcontent.php?counter=" + browserLines + "&nocache=" + Math.random(),true);
    				req.send();
    //    			setTimeout("loadXMLDoc()", 1500);
    			}
    I'm using AJAX, btw

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles