What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

To keep your animations moving...


theKeeper

Guru
Messages
2,313
Likes
63
I was just helping someone with this the other day and thought it might be useful for some members here. Especially those new to html or gif animations.

Here's the problem:
You have an animated gif running on your page, but when a user clicks a link that opens a new window, the animation stops running.

Here's the solution:
This situation is fairly simple. Just use a javascript function that will force the gif ani to reload, every so many seconds.

This is the code, and how it works:

Put this between the HEAD tags in your page:
-----------------------------------------------------------------------
<script language="JavaScript" type="text/javascript">
<!--
function reloadImage()
{
document.myImage.src = "toTop.gif";
}
//-->
</script>
-----------------------------------------------------------------------

Within the tag code for your image, insert this: name="myImage" (use whatever name _you_ want. Use no spaces though!) In the above Javascript code, replace the gif image (toTop.gif) to your own animation. If your animated gif is within an "image" folder and NOT in the same folder as the html page is, then add that to the image path in the Javascript code: i.e. "images/toTop.gif" .

To make this whole thing work, insert this into the BODY tag of your html page: onLoad="setTimeout('reloadImage()',3000)"

The 3000 in this part of the code means 3 seconds. Generally you want this number to be the exact same as the length of your animation. So if your animation lasts 5 seconds, change this number to 5000. That way it'll reload exactly when the sequence is over. That should help to make the change less noticeable.


Any questions/problems just ask. :B
 

Back
Top