PDA

View Full Version : Im trying to create a vertical ticker tape page ?



scooby545
May 20th, 2010, 09:13 AM
Hi all,

am trying to create a page which will automatically scroll to the bottom, then go back to the top and start again.

im very new to javascript and have done my best to peice together bits of scripts that do simular things :) the code below is what ive managed to come up with, it sort of works but am sure is full of mistakes :confused:



<SCRIPT type='text/javascript'>


var CurrentScroll=0;
var maxDisplacement=0;

function pageReset() {
CurrentScroll=0;
window.scrollTo(0,0);
}

function pageScroll() {

window.scrollTo(0,10000000);

if( typeof self.pageYOffset!='undefined' ){
maxDisplacement=self.pageYOffset;
}
if( document.compatMode && document.compatMode != 'BackCompat' ){
maxDisplacement=document.documentElement.scrollTop ;
}
if( document.body && typeof(document.body.scrollTop)!='undefined' ){
maxDisplacement=document.body.scrollTop;
window.scrollTo(0,0);
}

while(CurrentScroll <= maxDisplacement){
window.scrollBy(0,1); // horizontal and vertical scroll increments
scrolldelay = setTimeout('pageScroll()',100); // scrolls every 100 milliseconds

CurrentScroll = (CurrentScroll + 1);
}

if(CurrentScroll == maxDisplacement){
pageReset();
}

}


</SCRIPT>


if anyone can help it would be greatly appreciated

thanks in advance

Scoob :thumbsup: