maartenvr, you cannot trigger an animated GIF’s animation within the page. The only way you could technically achieve the effect would be to embed the image within an iFrame and then have the link reload the page (causing the animation to reoccur) through the target attribute. It’s deprecated and it’s pretty ugly, but it would do the job. This is another downside of GIF animation, it has no event triggers or method of calculating when an animation should work.
Technically you could have an animated GIF sprite which has a static version against an animated one which never changes and then trigger the effect on rollover, though the OP wanted it onclick, and the only way to cause that effect would be through CSS3 selectors (via anchors) to denote the change. And the problem with that (using the target attribute) is that it would only work on the initial click… that and it’s totally unsupported by Internet Explorer.
If you know exactly how long the animation lasts, you could also have a setTimeout that replaces the animated version with the static one once the animation is finished. Then you can repeat the process when the user clicks the image. GIFs have a “loop times” property which you can set to 1 to effectively stop it from looping. Then it’s a simple case of swapping images. If the first frame in the GIF is identical to the last, then you don’t even need a static image after the first run and you just need to set the src to the same thing again (this.src = this.src).
Not really, JavaScript can handle this easily by preloading the image, using event listeners and swapping the src attribute.