Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 100789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:38:47+00:00 2026-05-11T00:38:47+00:00

Hopefully, this will be an easy answer for someone with Javascript time behind them…

  • 0

Hopefully, this will be an easy answer for someone with Javascript time behind them…

I have a log file that is being watched by a script that feeds new lines in the log out to any connected browsers. A couple people have commented that what they want to see is more of a ‘tail -f’ behavior – the latest lines will always be at the bottom of the browser page until the viewer scrolls back up to see something. Scrolling back to the bottom should return you to the auto-scrolling behavior.

My google strikeout on this one is – hopefully – just a matter of not knowing anything at all about javascript and therefore, not knowing what keywords to search for. I don’t need a complete solution – just a ‘close enough’ that lets me jump in and get my hands dirty.

EDIT:

I’ve been attempting the scrollTop/scrollHeight idea, but am clearly missing something. I’ve done next to nothing with Javascript, so again I’m probably asking very low-level questions:

<html><body> <script type='text/javascript'> for (i=0; i<100; i++) {     document.write('' + i + '<br />');     document.scrollTop = document.scrollHeight; } </script> </body></html> 

This was one of many permutations. Obviously, I can’t output the log line-by-line in javascript, but I’m just trying to see the correct behavior. What’s the missing link I need here?

EDIT AGAIN: This has turned into a far more interesting problem that I first expected. The code suggestion using window.scroll does do the trick. I started playing with restricting the scroll to only take place when the browser was at the bottom of the document body. This is easy enough to do in theory, but in practice it hits a snag:

Every time you get new text from the server, the size of the body increases and your current scroll position is no longer at the bottom of the document. You can no longer tell the difference (using scrollHeight, clientHeight and scrollTop) whether the user has scrolled up or if the text has just shot beyond their view.

I think that if this is going to work, I’m going to have to commit myself to having a JS event that fires when the user scrolls and turns off scrolling if they are above the bottom of the window, but turns it back on if they have scrolled down to the point where they are effectively at the bottom of the view. I’m looking at the onScroll event and, given that the math on the variables I mentioned works out pretty well, I think I am on the right path here. Thanks for your input, everyone!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:38:48+00:00Added an answer on May 11, 2026 at 12:38 am
    x = 0;  //horizontal coord y = document.height; //vertical coord window.scroll(x,y); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Did you try refreshing (right click -> refresh) the project… May 11, 2026 at 1:04 pm
  • added an answer Your timeObjects is a delayed-execution enumerable. If you enumerate over… May 11, 2026 at 1:04 pm
  • added an answer The short answer is Yes. The things you should take… May 11, 2026 at 1:04 pm

Related Questions

Hopefully, this will be an easy answer for someone with Javascript time behind them...
This will hopefully be an easy one. I have an F# project (latest F#
Hopefully this will not spark a religious war... We have a web based app
Hopefully this is a simple one, but can anyone provide some simple c# code
Hopefully this still falls within StackOverflow's umbrella! I'm looking to create a quick boot
Simple question, hopefully an easy way and just want to verify I'm doing it
This morning, I was reading Steve Yegge's: When Polymorphism Fails , when I came
I've got a highly multithreaded app written in Ruby that shares a few instance

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.