/    Sign up×
Community /Pin to ProfileBookmark

Basic JS stop function help

Hello all,
Now to get the ball rolling, I am not too good at the whole javascript thing, I am still learning. This seemed like a great place to get some ideas on how to write this…

Currently I am trying to develop a reall simple menu, and in this menu I want some very basic animation on hoverover. So I got the hoverover to work like a champ, but it wont stop ? I was wondering how do you write a second function to get the first one to stop doing whatever it is its doing. This is what I got.

[B]<script>

var SlideShowSpeed = 200;
var Picture = new Array();

Picture[1] = ‘ud.GIF’;
Picture[2] = ‘bltr.GIF’;
Picture[3] = ‘lr.GIF’;
Picture[4] = ‘tlbr.GIF’;

var tss;
var i;
var jss = 1;
var pss = Picture.length-1;

var preLoad = new Array();
for (i = 1; i < pss+1; i++){
preLoad[i] = new Image();
preLoad[i].src = Picture[i];}

function runSlideShow(){
if (document.all){
document.images.PictureBox.style.filter=”blendTrans(duration=.2)”;
document.images.PictureBox.filters.blendTrans.Apply();}
document.images.PictureBox.src = preLoad[jss].src;
if (document.all) document.images.PictureBox.filters.blendTrans.Play();
jss = jss + 1;
if (jss > (pss)) jss=1;
tss = setTimeout(‘runSlideShow()’, SlideShowSpeed);
}

if (document.images)
{
pic1off= new Image(15,15);
pic1off.src=”ud.gif”;
}
</script>
[/B]

Pretty basic, I know, all it does is do a slideshow, switches between 4 pictures. Great…. now heres what I have for the HTML code:

[B] <td width=1024 height=768>
<A HREF=”test.html” onMouseover=”runSlideShow();” onMouseout=”[COLOR=Red]???[/COLOR]“>
<img src=ud.GIF name=PictureBox width=15 height=15>[/B]

so this is my delima… I need a second function to stop the first function onMouseout, and return to the original picture… I tried writing a return; function, but I dont think I did it right. Any ideas? Like I said, its really a simple question (at least it seems it would be).

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@JPnycAug 01.2006 — onmouseout="clearTimeout(tss)"
Copy linkTweet thisAlerts:
@mattna4authorAug 01.2006 — simple as that??????????

.....huh..... simple as that.......now that I look at it... that makes sense... I didnt know there was a clear command.

dang your good ? ok, not that this is a BIG deal, but how do you get the original picture to display again? As is with your solution, it just stops on whatever picture it finished on... not that I cant make that work for me... I was just curious ?
Copy linkTweet thisAlerts:
@JPnycAug 01.2006 — onmouseout="clearTimeout(tss);i=0"

By the way, that slideshow won't work at all in opera. You need to test for

if(document.all&&!window.opera) for the test to work in Opera.
Copy linkTweet thisAlerts:
@mattna4authorAug 01.2006 — ok... ill keep that in mind. I'm thinking about building the site in Flash, and having the javascript run in the background of that... I dont know if that will work though, I'm still just testing the waters in general with it.

But seriously, thanks for the help... I wish I understood js better than I do... but Im sure that will all come with time

Thanks!
×

Success!

Help @mattna4 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...