PDA

View Full Version : Stop animation with 1 click



the1knight
03-05-2007, 12:15 PM
Hi, new here.

I'm looking for a simply html script, or whatever is recommended, that will stop an animation playing with 1 click.

I would prefer something that would allow for image transparency.

For your information, it is to stop the scales you see in the header on this site. (http://www.freewareontrial.com)

Thanks in advance

jscheuer1
03-05-2007, 03:37 PM
What you have there is an animated .gif image. The easiest thing to do would be to have another version of the same image that isn't animated. It can have the same image transparency as the animated version. Then all you would need is a simple script to swap the images. Here is the images code in the source file:


<img src="images/Truth_or_justice.gif" width="110" height="90">

If you were to do something like so:


<img onclick="this.style.display='none';document.images[1].style.display='';" src="images/Truth_or_justice.gif" width="110" height="90"><img src="images/Truth_or_justice_plain.gif" width="110" height="90" style="display:none;">

Then just clicking on it would stop the animation.

Even easier and requiring no clicking would be to edit the image you have and make it so that it only loops a few times and then stops on its own. This can be easily done in any animated .gif editing software.

tech_support
06-02-2007, 10:20 AM
Sorry for bringing this thread back from the graveyard, but how would you stop it using JS?

I think there's no way you could do this though.

jscheuer1
06-02-2007, 01:48 PM
As I already outlined, by replacing it with a single frame version of itself. This could actually be done the way I mentioned, or by changing the src attribute of the image tag, or by many other ways as well.

mburt
06-02-2007, 03:22 PM
But there's no way to reliably track which frame is currently being used and to replace it with a single image. Unless it's a timed thing where you know exactly where to replace the image, this seems impossible.

jscheuer1
06-02-2007, 03:40 PM
Oddly, in IE (v 6 and less, at least) there is a bug of sorts (not really a bug, but a very literal interpretation of javascript) that allows for that simply with a link like so:


<a href="javascript:void(0);">Stop Animation</a>

But, it could also create other problems. For that type of precision in general, stopping an animation in its tracks as it were using javascript, an animated slide show would be best. Another way to get that utility without javascript is Flash.

mburt
06-02-2007, 05:51 PM
The void(0); may cause other things to crash if it is a bug in IE, and I wouldn't recommend using it. It seems the only way to do this reliably would be to have a Javascript animation and then you'd be able to control how you want to.

jscheuer1
06-03-2007, 02:17 AM
The void(0); may cause other things to crash if it is a bug in IE, and I wouldn't recommend using it. It seems the only way to do this reliably would be to have a Javascript animation and then you'd be able to control how you want to.

Isn't that what I just said? If you've nothing to add, why do you bother? Trying to up your post count?

tech_support
06-03-2007, 02:51 AM
Thanks guys.


Isn't that what I just said? If you've nothing to add, why do you bother? Trying to up your post count?
As far as I know, mburt added info. from your post.

jscheuer1
06-03-2007, 03:02 AM
Thanks guys.


As far as I know, mburt added info. from your post.

Well, if it gave you any information mine did not, I'm not sure what that would be. But, if it did, I guess It was a helpful post. I didn't see any new information there though.