473,461 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Scrolling Div Content.

Hey all,
I'm trying to scroll the content of a div tag up and down.
I've gotten that to work but, I need it to keep scrolling while the
mouse is over the image.
This is the code that I have at the moment.

function scrollUp(div)
{
// we first have to get the position of the div.
var topOfDiv = div.scrollTop;
var heightOfDiv = div.scrollHeight;

// now we have to check that the div when scrolling up doesn't scroll
past the top.
if(topOfDiv 0)
{
div.scrollTop = div.scrollTop - (div.scrollAmount = 8);
setTimeout(scrollUp(div), 1); <-- this is where I'm having trouble.
}
}

I can't get the setTimeout to work with the scrollUp argument.
I'm trying to get it to scroll up the content of the div slowly so
that it is a visible process and doesn't just jump from end to end.
which it does at the moment.

Feb 9 '07 #1
3 10293
On Feb 9, 7:09 am, "Nalum" <mallon.l...@gmail.comwrote:
Hey all,
I'm trying to scroll the content of a div tag up and down.
I've gotten that to work but, I need it to keep scrolling while the
mouse is over the image.
This is the code that I have at the moment.

function scrollUp(div)
{
// we first have to get the position of the div.
var topOfDiv = div.scrollTop;
var heightOfDiv = div.scrollHeight;

// now we have to check that the div when scrolling up doesn't scroll
past the top.
if(topOfDiv 0)
{
div.scrollTop = div.scrollTop - (div.scrollAmount = 8);
setTimeout(scrollUp(div), 1); <-- this is where I'm having trouble.
}

}

I can't get the setTimeout to work with the scrollUp argument.
I'm trying to get it to scroll up the content of the div slowly so
that it is a visible process and doesn't just jump from end to end.
which it does at the moment.

setTimeout(scrollUp(div), 1); is incorrect. you can't pass your
function call a parameter in this case - scrollUp(div).
setTimeout should be called like this: setTimeout(function,
milliseconds)
you have it like this setTimeout(function call, milliseconds)
try wrapping that call inside a function instead:

setTimeout(function() {scrollUp(div)}, 1);

does that do it?

Feb 9 '07 #2
On Feb 9, 3:23 pm, "Walton" <jrhol...@gmail.comwrote:
On Feb 9, 7:09 am, "Nalum" <mallon.l...@gmail.comwrote:
Hey all,
I'm trying to scroll the content of a div tag up and down.
I've gotten that to work but, I need it to keep scrolling while the
mouse is over the image.
This is the code that I have at the moment.
function scrollUp(div)
{
// we first have to get the position of the div.
var topOfDiv = div.scrollTop;
var heightOfDiv = div.scrollHeight;
// now we have to check that the div when scrolling up doesn't scroll
past the top.
if(topOfDiv 0)
{
div.scrollTop = div.scrollTop - (div.scrollAmount = 8);
setTimeout(scrollUp(div), 1); <-- this is where I'm having trouble.
}
}
I can't get the setTimeout to work with the scrollUp argument.
I'm trying to get it to scroll up the content of the div slowly so
that it is a visible process and doesn't just jump from end to end.
which it does at the moment.

setTimeout(scrollUp(div), 1); is incorrect. you can't pass your
function call a parameter in this case - scrollUp(div).

setTimeout should be called like this: setTimeout(function,
milliseconds)
you have it like this setTimeout(function call, milliseconds)

try wrapping that call inside a function instead:

setTimeout(function() {scrollUp(div)}, 1);

does that do it?
Thanks for your reply.
I figured out a way to do it a little bit before you replied to this.
Though I will check what you have told me.
Below is how I got it to work.

setTimeout("scrollUp(document.getElementById('"+di v.id+"'))", 1);

Feb 9 '07 #3
setTimeout("scrollUp(document.getElementById('"+di v.id+"'))", 1);

oh yes! putting the function call in quotes works as well. not as
graceful in my opinion though ;-)

Feb 9 '07 #4

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

Similar topics

4
by: Cat Laugel | last post by:
Hello, I am redesigning my website and would like to have the text scroll within the webpage without the page itself scrolling.... if you understand what I mean... ;-) I want a very sleek look...
3
by: spencer | last post by:
Hello, I have an index page with an autoscroller writen with CSS. The problem is the scrolling content(text and inages)'s position is correct but will off position when the broswer(IE) window...
4
by: mr_burns | last post by:
Hi, Is it possible to disble horizontal scrolling using CSS? I want to try and use two backgrounds, one tiling vertically and part of the body background, which will not force scrolling, but one...
44
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...
4
by: headware | last post by:
I have a <select> control that contains many entries. It allows the user to multi-select a group of them, click a button, and store the selected data in a database. Normally they do this starting...
9
by: Mark Horrell | last post by:
I'm having problems getting scrollbars to appear using the 'scrolling' attribute of the 'iframe' tag, and I'm wondering if anyone can help me. I would expect the following code to produce a...
2
by: Fabrizio | last post by:
Hi, I'm trying to deal with ASP.NET and i would like to know if there is any control or any method that allows me, like in JAVA classes, to have, for example, scrolling news with links to...
2
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...
7
by: seven.reeds | last post by:
Hi, I have a caontainer div that is 80% of the width of my display and 40em high. It will hold from 2 to 10 columns of data and will almost always have more than 40ems of lines... so it will...
0
by: eelziere | last post by:
Hi All, I found the http://www.thescripts.com/forum/thread644980.html discussion, but none of the proposed solutions worked for me. Thanks in advance for your help! * The site:...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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
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
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...

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.