473,396 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

java script to show last lines of textarea

Hi every one,

I have a question regarding the lastline in Textarea. I am have build a chat application using the textarea to display the typed messages. Every thing is working fine except once the text range is out of the textarea size I have to scroll down to check for the new messages. Can anyone help me to display the last lines of in textarea always using javascript.


Thanks & Regards,

Bharat
Feb 2 '08 #1
2 3921
gits
5,390 Expert Mod 4TB
hi ...

have a look at the following example:

Expand|Select|Wrap|Line Numbers
  1. var n   = document.getElementById('your_message_text_area_id');
  2. var end = n.lastChild.offsetTop;
  3. window.scrollTo(0, end);
so we refer to the div where you output the messages, and then we refer to its last added child ... and then we scroll to its top position ... note: i assume that it is a div where you assign the messages to? typically you have an input area (to type in) below or before an readonly messages-output 'window' (where the recent messages appear)?

kind regards
Feb 4 '08 #2
HI,

I hope below things will work for you.

Expand|Select|Wrap|Line Numbers
  1. obj = document.getElementById(divid);
  2.         var currentScrollHeight = obj.scrollHeight;
  3.         obj.scrollTop = (obj.scrollTop + 100000); //set the scroll height to scroll by here.
srini
Apr 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
5
by: Mark Szlazak | last post by:
Apparently there is a textarea onscroll event bubbling bug in Firefox and Mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=229089 I'm trying to check for this bug with the following...
5
by: Papajo | last post by:
I,m looking for a script to remove duplicates email addresses from a list, the addresses will be displayed one per line in a textarea. The script will be used on a simple webtv browser. Thanks Joe
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
0
by: crispinternet | last post by:
hi there, well its been 3 days and still i cant find the solution to a problem i have, im on the last bot of a long project and cant seem to get this working. basically i have a signature applet...
3
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
1
by: twin2003 | last post by:
need help with inventory part 5 here is what I have to do Modify the Inventory Program by adding a button to the GUI that allows the user to move to the first item, the previous item, the next...
4
lifeisgreat20009
by: lifeisgreat20009 | last post by:
This is what i am getting on running the program......... C:\PROGRA~1\Java\JDK15~1.0\bin>javac Editor.java Note: Editor.java uses or overrides a deprecated API. Note: Recompile with...
4
cassbiz
by: cassbiz | last post by:
Could use some help here. This script is carrying over an image just fine but the text isn't coming over. can you see why it is not working???? from the form I want to carry over two lines of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.