I need to detect when a user arrives at the end of a readonly textarea in an html page.
The textarea will display a very long log for an application. The logs files are so big that is impossible to load all the text in one time (some log files are almost 200 MB). So I will load the first, say, 1000 lines, and then I need to detect when the user is near the last line of the loaded text to give him the next n lines via an ajax call.
What is the best way to detect this event?
You should compare the textarea.scrollHeight
to the textarea.scrollTop
- the closer they are, the closer you are to the end of your text area.
You could work with the caret position (checking where it is and comparing it to your length).
Or, you could work with the scrollbar position. (or a combination of both)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With