Forum Moderators: open
I have a page with a table. This table can grow to any size. When the table only has enough values to fit a page, it's fine. When the table has enough information to span two pages, then I am trying to set intervals to show the first page for 10 sec, and then the (page down)second page for 10 sec, and so on...
The algorithm I am trying to do is:
1. Find the vertical scrolling for a page.
2. Based on the vertical scrolling, I pick an arbitrary number (I cannot find the size of pressing page down!) and try to determine the # of pages
// Determines how many pages
if (verticalscroll > 300)
{
for(i=0; i<=scrOfY; i=i+500)
{
pages = pages + 1;
}
}
3. Set a loop based on how many pages...
for(j=0; j <= pages; j++)
{
setInterval('window.scroll(0,"count")', 10000);
count = count + 500;
}
I'm having some trouble with the logic and getting this page to do what I want it to. Does anyone know of a better solution or what is wrong with mine? Also, this method is called onLoad()...
for(j=0; j <= pages; j++)
{
setInterval('window.scroll(0,"count")', 10000);
count = count + 500;
}
with
currTmout=0;
for(j=0; j <= pages; j++)
{
currTmout=eval(eval(currTmout)+eval(10000));
window.setTimeout('window.scroll('+count+')', currTmout);
count = count + 500;
}
thanks for responding, unfortunately I do not have this site up yet.
I tried what you suggested but it doesn't quite work right. It goes to the very top, waits 10 secs, then goes to the bottom. If the page is three screens long, then I will not see the second page. I found that the behavior that I want is something like this...
// I want this to run in an infinite loop and rotate...
while(1)
{
window.scroll(0 , count);
// This will stop the loop until I click ok
alert("Did I Move?");
// Divide the page equally
count = count + (scrOfY/pages);
// Reset the page
if(count > scrOfY)
count=0;
}
If I remove the "alert" everything goes crazy, putting in a "setTimeout" does not seem to work. Any ideas?
This is the problem. I did find a script that actually makes the js stop and wait, but that script is breaking my machine. It breaks the other javascript in the page and causes IE to be unresponsive.
I know there's something wrong with my logic, since know I need this in a loop, can I just do a setTimeout on page load?
What's the difference between a setTimeout and a setInterval?