/    Sign up×
Community /Pin to ProfileBookmark

Image animation loop

Hey, I’m trying to make an animation that repeats over and over again, I need the script to be short, so I was wondering if someone could modify this one for me?

[code]
<HTML>
<HEAD>
<title>JavaScript Example</title>
<SCRIPT type=”text/javascript”>
function up()
{
document.mypic.src=”up.gif”
}
function down()
{
document.mypic.src=”down.gif”
}
</SCRIPT>
</HEAD>
<BODY>
<CENTER>
<h2>Sample Animation</h2>

<A HREF=”http://www.htmlgoodies.com”
onMouseOver=”up()”
onMouseOut=”down()”>
<IMG SRC=”down.gif”
NAME=”mypic”
BORDER=0>
</BODY>
</HTML>[/code]

I need it so that instead of the onMouseOver and onMouseOut, it starts automaticly playing the two images over and over again.

Oringinaly I was useing an HTML <SPAN> code, but whenever I wanted to edit it it would take days to retype each field.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@tabzterOct 02.2005 — <SCRIPT type="text/javascript">

function up()

{

document.mypic.src="up.gif";

setTimeout("down()",500);

}

function down()

{

document.mypic.src="down.gif";

setTimeout("up()",500);

}

up();

</SCRIPT>[/QUOTE]


Now get rid of the [B]OnMouseOver="..."[/B] and [B]OnMouseOut="..."[/B] parts from the <A> tag.

PS. close your element tags i.e. <a><img>...[B]</img></a>[I][/I][/B]
Copy linkTweet thisAlerts:
@Tweak4Oct 03.2005 — PS. close your element tags i.e. <a><img>...[B]</img></a>[/B][/QUOTE]

Unless something has changed no one has told W3C yet, the <img> tag doesn't have a closer. "</img>" is not valid. (However, the <a> should indeed be closed properly)
Copy linkTweet thisAlerts:
@tabzterOct 03.2005 — There is no harm in closing </img>. Actually [B]when[/B] you have to upgrade to XHTML it will be a requirement, so you might as well get rid of the ball ache now.
×

Success!

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