/    Sign up×
Community /Pin to ProfileBookmark

2 mods for vertical scroller script

This will probably be painfully simple, but I’m clueless. I need to modify the script below to scroll only once, then return to the top – rather than looping endlessly.
Also, I’d like to invoke it with a link rather than an onload.
Finally, the script works in every browser I’ve tried except IE 6 for Windows. No problem in Firefox or on a Mac using Safari, Opera & IE.
See any obvious glitches that would break it with win IE?

here’s the script, which I’ve pasted in the body of the frame page:

<script language=”JavaScript1.2″ type=”text/javascript”>
<!–
var speed=1
var currentpos=0,alt=1,curpos1=0,curpos2=-1
function initialize(){
startit()
}
function scrollwindow(){
if (document.all)
temp=document.body.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=document.body.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>

Thanks for any help,
Kelly

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Warren86Jan 03.2005 — Your code, modified as requested is contained within the attached. It's merely a "tester," with the scroll speed set to 30, instead of 1.

[upl-file uuid=62ffd5dc-ab4b-4619-931a-3fe0d13a011d size=7kB]auto scroll tester.txt[/upl-file]
Copy linkTweet thisAlerts:
@artpotteryauthorJan 04.2005 — thanks, it does exactly what I need it to.

For whatever reason, it still won't work in Windows IE - executes flawlessly on everthing else.
Copy linkTweet thisAlerts:
@pj59Jan 04.2005 — [i]Originally posted by artpottery [/i]

[B]For whatever reason, it still won't work in Windows IE - executes flawlessly on everthing else. [/B][/QUOTE]
Just check your IE settings. Both your original code and Warren86's stuff do work in Windows IE.

PJ
Copy linkTweet thisAlerts:
@artpotteryauthorJan 17.2005 — I've tried everything over the past few weeks. The only way this autoscroller will work in windows IE is if I omit the:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">


Is there a workaround or tweak so the page will still validate?

code's below

Thanks

Kelly


<script language="JavaScript" type="text/javascript">

<!--

var speed=1;

var currentpos=0;

var alt=1;

var curpos1=0;

var curpos2=-1;

function scrollWindow(){

if (document.all)

temp=document.body.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=document.body.scrollTop+speed}

else {currentpos=window.pageYOffset+speed}

window.scroll(0,currentpos)

}

else{window.scroll(0,0);clearInterval(isDelay)}

}

function startit(){

isDelay = setInterval("scrollWindow()",1)

}

//-->

</script>

</head>

<body>

<a name="top"></a>

<a href="javascript:startit()">Auto Scroll</a></div>
Copy linkTweet thisAlerts:
@artpotteryauthorJan 18.2005 — I failed to add: the scroller is running in a frame.
×

Success!

Help @artpottery spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...