Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Auto Scroll to Bottem
Old 11-10-2006, 12:29 PM Auto Scroll to Bottem
Junior Talker

Posts: 1
Trades: 0
I am trying to autoscroll to the botem of a page, and then back up again. I would like it to scroll down, wait about 5 sec, then scroll back up to the top, wait another 5 sec, then do the whole thing over again. Im a uber jscript noob so bare with me here What I have so far is below...

function start1 starts the scrolling down
function start2 starts the scrolling up
function stop1 halts scrolling
function top1 just leeps back up top

i would like this to happen body onload, and it just does its thing.. i know this is simple, but im not at the simple level quite yet
thanks in advance!

<SCRIPT LANGUAGE="JavaScript">

var timeout;
var y = 0;
var step = 4;

function start1(){
if (y < 0){
y=0;
}

window.parent.scroll(0,y);
y=y + step;

timeout=setTimeout("start1()",100);
}

function start2(){
if (y >=0 ){
window.parent.scroll(0,y);

y = y - step;
}

timeout=setTimeout("start2()",100);
}

function stop1(){
clearTimeout(timeout);
}

function top1(){
window.parent.scroll(0,0);

y=0;
}

</SCRIPT>
NastyMcPimpStik is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-11-2006, 09:35 AM Re: Auto Scroll to Bottem
Novice Talker

Posts: 9
Location: Russian Federation
Trades: 0
NastyMcPimpStik
Try something like that:
Code:
 
function page_size() {
  var y, h;
  if(window.innerHeight && window.scrollMaxY)
    y = window.innerHeight + window.scrollMaxY;
  else if(document.body.scrollHeight)
    y = document.body.scrollHeight;
  else y = document.body.offsetHeight;
  if(window.innerHeight) h = window.innerHeight;
  else if(document.documentElement && document.documentElement.clientHeight)
    h = document.documentElement.clientHeight;
  else if(document.body) h = document.body.clientHeight;
  return ((y > h) ? y + 20 - h : false);
}
function init_scroll() {
  init_scroll.height = page_size();
  if(init_scroll.height) {
    init_scroll.y = 0;
    init_scroll.step = 50;
    make_scroll();
  }
}    
function make_scroll() {
  var y = (init_scroll.y += init_scroll.step);
  if(y >= 0 && y <= init_scroll.height) {
    window.scroll(0, y);
    setTimeout(make_scroll, 10);
  }
  else {
    init_scroll.step = -init_scroll.step;
    setTimeout(make_scroll, 2000);
  }
}
onload = init_scroll;
_ru_ is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Auto Scroll to Bottem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26158 seconds with 12 queries