/    Sign up×
Community /Pin to ProfileBookmark

images problem

Hi dudes ?
I`m making web page that contains 4 images. When start javascript function should change the images in a row with 5 seconds delay

This is the code:

<html>
<head>
<script>

function over(val) {
document.images[val].src = “images/red.png” ;
}

function out(val) {
document.images[val].src = “images/blue.png” ;
}

</script>
</head>

<body onLoad=”strt()”>

<script>
function strt() {
for (i=0;i<4;i++) {
over(i);
sleep(5);
out(i);
}
}
</script>

<center>
<a href=”http://www.abv.bg” onMouseOver=”over(0)” onMouseOut=”out(0)”><img src=”images/blue.png”></a>
<a href=”http://www.dir.bg” onMouseOver=”over(1)” onMouseOut=”out(1)”><img src=”images/blue.png”></a>
<a href=”http://www.data.bg” onMouseOver=”over(2)” onMouseOut=”out(2)”><img src=”images/blue.png”></a>
<a href=”http://www.setcom.bg” onMouseOver=”over(3)” onMouseOut=”out(3)”><img src=”images/blue.png”></a>
</center>

</body>

</html>

but the script don`t work. it don`t change the images.
what did i wrong

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JonaApr 14.2005 — [font=Trebuchet MS]Take out the [i]sleep(5);[/i] part. JavaScript doesn't have a sleeping function, so you'll have to run one loop to call the first function (over), then a setTimeout call to another function (or the same function with a different switch) to run a loop for the second function call (out).[/font]
×

Success!

Help @adr 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,
)...