473,503 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scrolling in div

Hello all - I'm trying to get a div element to scroll down when a new
line of html is added to it. Here's my div element:

<div id="initialtext"
style="height:185px;width:390px;overflow:scroll;z-index: 91; position:
absolute; visibility:visible;left:15px;top:67px;"></div>

And I have a function that adds text to this div:

function addText(t)
{
var d = document.getElementById("initialtext");
if (d)
{
d.innerHTML+=t;
// Now I want the div to scroll down so I can see the
new line!
}
}
I've tried doScroll(), scrollTop(), and a bunch of other ideas I found
in this group but cannot get anything to work! Thanks much for any
input!
Jul 23 '05 #1
2 1587
ch***@milwaukeejobs.com wrote in message news:<e0**************************@posting.google. com>...
Hello all - I'm trying to get a div element to scroll down when a new
line of html is added to it. Here's my div element:

<div id="initialtext"
style="height:185px;width:390px;overflow:scroll;z-index: 91; position:
absolute; visibility:visible;left:15px;top:67px;"></div>

And I have a function that adds text to this div:

function addText(t)
{
var d = document.getElementById("initialtext");
if (d)
{
d.innerHTML+=t;
// Now I want the div to scroll down so I can see the
new line!
}
}
I've tried doScroll(), scrollTop(), and a bunch of other ideas I found
in this group but cannot get anything to work! Thanks much for any
input!


Try:

function addText(id, txt)
{
var el;
if (el = document.getElementById(id))
{
el.innerHTML += txt;
if (typeof el.scrollTop != 'undefined')
setTimeout('document.getElementById("'+id+'").scro llTop=5000;', 50);
}
}
Jul 23 '05 #2
It works! Thanks so much!

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
16663
by: Midas NDT Sales | last post by:
I have been looking at a simple example of a scrolling text box (the one in the SAM book) as below: <script language="JavaScript"> var pos=100; function Scroll() { if...
1
7014
by: Kirk | last post by:
Is it possible to stop horizontal scrolling whilst still maintaining vertical scrolling within an <IFRAME> ? Within each page of my site I have an IFRAME for content. For some pages there is...
44
919
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
1
2158
by: Tim Frawley | last post by:
I have a large form with many controls, almost like legal size paper in height. Just so I can head these off, I am not looking for suggestions to the effect of using Tab controls, multi-window...
2
2940
by: P2P | last post by:
Hi I am wondering if someone know of a free cross-browsers vertical scrolling script that - is cross cross-browsers - will call the scrolling content from an external html page or from a...
4
7739
by: Keith Bentrup | last post by:
Hi all, I wrote a simple search function to find text in a textarea where not all the text is visible (ie. the text box displays 10 lines but there may be more than 1000 lines to search). I can...
1
1841
by: atif | last post by:
Hi, I m new to CSharp.. so may be my preliminary questions look stupid.. but plz help me.. I want to drag controls like buttons or some other user controls over form.. i have set form's...
5
4228
by: PythonistL | last post by:
I am a newbie with Javascript. I have this simple script for scrolling text <HTML> <HEAD> <TITLE>Scrolling Message Script</TITLE> <SCRIPT language="JavaScript"><!-- var msg = 'My scrolling...
3
11716
by: Chamnap | last post by:
Hello everybody, I have one problem. I want to do something after the user finished scrolling. The scroll event fires whenever the user is scrolling. I don't want this actually. Does anyone has...
0
7201
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
7083
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7456
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
5578
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,...
1
5011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3166
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1510
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
379
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.