PDA

View Full Version : Page Auto Scroll Problem



davidjohny
07-15-2008, 09:09 PM
Hi
I have a very simple problem but I do not know how to fix it.

I am using the auto scroll script from the below page
http://www.dynamicdrive.com/dynamicindex8/topscroll.htm

On page refresh it automatically scrol down the page and then
scroll up to top and then again scroll down and then again move up to Top and keep scrolling the page from top to down and then up and then down(LOOP process)


:: What I want ::
I want to just automatically scroll down the page and do not scroll up to Top again. DONE!

OR

After scrolling down wait for some 2 minutes and then auto scroll the page up to Top


Below is the script that I am using
Please some one fix this for me.

===============================================
<script language="JavaScript1.2">

/*
Top-Down scrolling window Script- Dynamic Drive (www.dynamicdrive.com)
For full source code, visit http://www.dynamicdrive.com
This notice MUST stay intact for use
*/

//change 1 to another integer to alter the scroll speed. Greater is faster
var speed=1
var currentpos=0,alt=1,curpos1=0,curpos2=-1
function initialize(){
startit()
}

function iecompattest(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}

function scrollwindow(){
if (document.all)
temp=iecompattest().scrollTop
else
temp=window.pageYOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
currentpos=iecompattest().scrollTop+speed
else
currentpos=window.pageYOffset+speed
window.scroll(0,currentpos)
}
else{
currentpos=0
window.scroll(0,currentpos)
}
}
function startit(){
setInterval("scrollwindow()",10)
}
window.onload=initialize
</script>
========================================================

rangana
07-16-2008, 12:12 AM
If you hate it going to top again, then remove the higlighted:


function scrollwindow(){
if (document.all)
temp=iecompattest().scrollTop
else
temp=window.pageYOffset
if (alt==0)
alt=1
else
alt=0


Hope it helps.

davidjohny
07-16-2008, 09:37 AM
Hi

I am removed the highlighted as you said but it is still not working.

Can some one fix the Auto Scroll to top problem?

davidjohny
07-17-2008, 07:52 AM
Hi

I am removed the highlighted as you said but it is still not working.

Please, Can some one fix the Auto Scroll to top problem??

rangana
07-17-2008, 08:07 AM
My apologies for not being with the thread. I've got a lot of work, anyway, that was my bad. Try to remove highlighted instead:


function scrollwindow(){
if (document.all)
temp=iecompattest().scrollTop
else
temp=window.pageYOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
currentpos=iecompattest().scrollTop+speed
else
currentpos=window.pageYOffset+speed
window.scroll(0,currentpos)
}
else{
currentpos=0
window.scroll(0,currentpos)
}
}


Hope it helps.

feezixora
07-23-2008, 04:44 AM
1st of all, i,m apologize for my bad english.
i just want to know, how about to make it scroll down at the some place and stop? i really need this trick. thanks

rangana
07-23-2008, 05:43 AM
Here's a modified version of the script:


<script type="text/javascript">

/*
Top-Down scrolling window Script- Dynamic Drive (www.dynamicdrive.com)
For full source code, visit http://www.dynamicdrive.com
Modified by Raymond Angana
rangana in dynamicdrive.com/forums
This notice MUST stay intact for use
*/

//change 1 to another integer to alter the scroll speed. Greater is faster
var speed=1
var currentpos=0,alt=1,curpos1=0,curpos2=-1,
limit=100; // Set the limit here
function initialize(){
startit()
}

function iecompattest(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}

function scrollwindow(){
if (document.all)
temp=iecompattest().scrollTop
else
temp=window.pageYOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
{
currentpos=(currentpos==limit)?iecompattest().scrollTop:iecompattest().scrollTop+speed;
}
else
currentpos=(currentpos==limit)?window.pageYOffset:window.pageYOffset+speed;
window.scroll(0,currentpos)
}
}
function startit(){
setInterval("scrollwindow()",10)
}
window.onload=initialize
</script>

Modifications were:

Added a limit (Highlighted sets the limit).
Scrolling stops on the set limit.


Hope that helps.

feezixora
07-24-2008, 11:14 AM
ooo thanks rangana. i will try it.

spyderfyre3
12-14-2008, 01:02 AM
After the script scrolls down to the area set in the limit. Is there a way to make ti terminate so that people can scroll through the page without the autoscroll interfering? Basically, I went it to autoscroll once to the area set in the limit then stop and no more autoscrolling happens again unless the page is refreshed. Can someone help?

BlackM00N
04-22-2011, 11:29 PM
i am trying to use that script too but i would like a small change to it.

it is good as it is, i don't mind it scrolling to the bottom, but i would like the scrolling to stop once someone is clicking anywhere on the page.

That would be so great !

Your help is much appreciated.

BlackM00N

rangana
04-23-2011, 12:12 AM
Modify startit() function to:


function startit(){
s = setInterval("scrollwindow()",10);
document.body.onclick = function() {
if(stop) {
startit();
stop = false;
}
else {
clearInterval(s);
stop = true;
}
}
}


...and add higlighted on the variable declaration part:


var currentpos=0,alt=1,curpos1=0,curpos2=-1,s,stop=false,


Hope that helps.

BlackM00N
04-23-2011, 12:26 AM
I think I did something wrong here, i am really a noob in this field :) Now it won't start scrolling at all


<script language="JavaScript1.2">

/*
Top-Down scrolling window Script- Dynamic Drive (www.dynamicdrive.com)
For full source code, visit http://www.dynamicdrive.com
This notice MUST stay intact for use
*/

//change 1 to another integer to alter the scroll speed. Greater is faster
var speed=1
var currentpos=0,alt=1,curpos1=0,curpos2=-1,s,stop=false,
function initialize(){
function startit(){
s = setInterval("scrollwindow()",10);
document.body.onclick = function() {
if(stop) {
startit();
stop = false;
}
else {
clearInterval(s);
stop = true;
}
}
}
}

function iecompattest(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}

function scrollwindow(){
if (document.all)
temp=iecompattest().scrollTop
else
temp=window.pageYOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
currentpos=iecompattest().scrollTop+speed
else
currentpos=window.pageYOffset+speed
window.scroll(0,currentpos)
}
else{
currentpos=0
window.scroll(0,currentpos)
}
}
function startit(){
setInterval("scrollwindow()",10)
}
window.onload=initialize
</script>

rangana
04-23-2011, 12:40 AM
Please surround your codes under
bbtag. Anyway, here's the modification (highlighted are the changes):


var speed=1
var currentpos=0,alt=1,curpos1=0,curpos2=-1,s,stop=false,
limit=100; // Set the limit here
function initialize(){
startit()
}
function iecompattest(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}
function scrollwindow(){
if (document.all)
temp=iecompattest().scrollTop
else
temp=window.pageYOffset
if (alt==0)
alt=1
else
alt=0
if (alt==0)
curpos1=temp
else
curpos2=temp
if (curpos1!=curpos2){
if (document.all)
{
currentpos=(currentpos==limit)?iecompattest().scrollTop:iecompattest().scrollTop+speed;
}
else
currentpos=(currentpos==limit)?window.pageYOffset:window.pageYOffset+speed;
window.scroll(0,currentpos)
}
}
function startit(){
s = setInterval("scrollwindow()",10);
document.body.onclick = function() {
if(stop) {
startit();
stop = false;
}
else {
clearInterval(s);
stop = true;
}
}
}
window.onload=initialize


Hope that helps.

BlackM00N
04-23-2011, 12:50 AM
Thank you, rangana

You have been a real help! Greatly appreciated!

Best regards,
BlackM00N

BlackM00N
04-23-2011, 08:26 AM
Hi, it's me again, script runs smooth but it needs a small adjustment to make it just perfect. now it is like click on page=stop scroll, click again=scroll again

i would like it to not start scrolling again once clicked. clicking on page should mean stop scrolling until page refresh.

another cool thing (for me) would be if it would scroll back up and then stop scrolling down again.
is that possible?

Thank you,
BM