stopping animated gifs

J

Jeff

Hi,

I'd like to write Javascript that stops animated gifs from animating.

On Firefox, at least, window.stop(); does the trick, although it stops
everything on the page and is kind of unpredictable. If I connect it
to the onload event, sometimes only half the page will be displayed.
Does the onload even fire before rendering?

Does anyone know a reasonable way to accomplish my original goal of
stopping animating gifs from animating?

Thanks,
Jeff
 
N

Neo Geshel

David said:
Well, animated gifs are not "animated" in any way that your script can
control. The gif is its own little file and will continue to cycle
through forever until you destroy or alter the img tag it's contained
in. Any other action you take to "freeze" the gif will be hacky and
likely not supported across browsers. I'd suggest taking a snapshot
of the GIF wherever you'd like it to stop, saving that as an image
file, then swapping the src attribute of your img tag in script at the
appropriate moment.

-David
If Jeff is looking to stop the GIF’s after a predetermined amountof
time, he would be better off editing the GIF’s themselves to loopfor a
specific number of times, rather than indefinitely. This has to be done
by hand with an image-editing program, and the newly edited GIF will
need to be re-uploaded to the site manually.

There is a possibility that it can also be done with CGI (such as
ASP.NET 3.0, PHP5 or Perl... it’s been a while since I edited a GIF
using ASP.NET), but a page refresh is required to produce an image with
a different number of repetitions every time.

However, I am getting the impression that he may be hotlinking the
GIF’s, because the easiest thing to do (to have a GIF that does not
animate at all) is to (sort of) use your method... to extract a single
frame of the animated GIF, save it as its own file, and use that
instead. If Jeff is hotlinking, and does not control the GIF in
question, then this could explain his question.

You are right, however, in that an animated GIF cannot be arbitrarily
stopped. It can only be replaced by another image that is static, or set
to stop after a specific number of repetitions.

I hope this helps.
...Geshel
--
*********************************************************************
My return e-mail address is an automatically monitored spam honeypot.
Do not send e-mail there unless you wish to be reported as a spammer.
Please send all e-mail to my first name at my last name dot org, with
a subject-line of “NEWSGROUP REPLY FOR NEO GESHEL†(all uppercase).
*********************************************************************
 
C

cwdjrxyz

Hi,

I'd like to write Javascript that stops animated gifs from animating.

On Firefox, at least, window.stop(); does the trick, although it stops
everything on the page and is kind of unpredictable. If I connect it
to the onload event, sometimes only half the page will be displayed.
Does the onload even fire before rendering?

Does anyone know a reasonable way to accomplish my original goal of
stopping animating gifs from animating?

Thanks,
Jeff

If you want to stop animations from all pages on your computer, you
usually can turn them off. For Windows XP OS: start > control panel >
network and internet connections > internet options > advanced >
multimedia > uncheck play animations in web pages. If on the other
hand you want to make a web page that will not animate for anyone
viewing it, you need to extract one frame from the animation and use
it instead. Many image programs will do this. For example, PaintShop
has a connected program called Animation Shop. Here it is easy to open
the animated gif to show all of the frames in it on the screen, and
then you can select and save the frame you like best as a standard
gif. I know of no way to use script on the page to stop an animated
gif, and think it would be a poor choice even if you could. Why would
one one to load all of the frames of an animated gif and then use only
one of them? I have seen animated gifs that were many hundred KB in
size, since someone was, in effect, using an animation as a slide
show! Such would slow down loading greatly if the viewing browser is
not on broadband. Such excesses are rare, thank goodness.
 
J

Jeff

If you want to stop animations from all pages on your computer, you
usually can turn them off. For Windows XP OS: start > control panel >
network and internet connections > internet options > advanced >
multimedia > uncheck play animations in web pages. If on the other
hand you want to make a web page that will not animate for anyone
viewing it, you need to extract one frame from the animation and use
it instead. Many image programs will do this. For example, PaintShop
has a connected program called Animation Shop. Here it is easy to open
the animated gif to show all of the frames in it on the screen, and
then you can select and save the frame you like best as a standard
gif. I know of no way to use script on the page to stop an animated
gif, and think it would be a poor choice even if you could. Why would
one one to load all of the frames of an animated gif and then use only
one of them? I have seen animated gifs that were many hundred KB in
size, since someone was, in effect, using an animation as a slide
show! Such would slow down loading greatly if the viewing browser is
not on broadband. Such excesses are rare, thank goodness.

Thanks to everyone that replied. I should have been a bit more clear
- I want to do this as part of a Greasemonkey script, which means that
I won't have control over the images and, therefore, can't do the
sensible thing and just make them non-animating from the start. I
knew that IE had the option to start animating gifs and I believe
Firefox has a setting that you can edit in its giant list of settings
that will accomplish the same, but I wanted a script that I could run
that could stop them from animating. Since it's Greasemonkey, hacks
are welcome - although I'd prefer to keep it cross-browser compatible
if possible.

The real application is for web accessibility. Animating gifs can be
more than just ugly - for some users they actually impair the user's
ability to concentrate on the content of the page.

-Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top