473,394 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

stopping animated gifs

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

Feb 16 '07 #1
4 6294
On Feb 16, 3:37 pm, "Jeff" <jeffrey.big...@gmail.comwrote:
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
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

Feb 17 '07 #2
David Golightly wrote:
On Feb 16, 3:37 pm, "Jeff" <jeffrey.big...@gmail.comwrote:
>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
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).
************************************************** *******************
Feb 17 '07 #3
On Feb 16, 5:37 pm, "Jeff" <jeffrey.big...@gmail.comwrote:
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.

Feb 17 '07 #4
On Feb 16, 9:06 pm, "cwdjrxyz" <spamtr...@cwdjr.infowrote:
On Feb 16, 5:37 pm, "Jeff" <jeffrey.big...@gmail.comwrote:
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.
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

Feb 17 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Shabam | last post by:
Does dot net support the resizing of animated GIFs? I've heard that it doesn't. Why is that, if it's true?
9
by: John J. Hughes II | last post by:
Is it possible using Image or Bitmap to build and save an animated GIF file? I am not have a problem saving the GIF file just getting the frames added to it. I did find ImageAnimator but it only...
2
by: Koen Hoorelbeke | last post by:
Hi there, I'm trying to read an animated gif from a url (for a banner-rotator). The code I have now, does read the gif (or jpg), but the result is that I only get the first frame of the animated...
0
by: GrandpaB | last post by:
I am creating a small simulation in VB and wish to incorporate several animated GIFS. I can load the GIFS from the hard drive into a picture box and they animate, but I have two questions. 1.)...
4
by: Helmut Giese | last post by:
Hello out there, this is OT but maybe some of you were in the past faced with the same problem: I have lots of sequences of GIF files to combine into animated GIFs. I can do it 'by hand' with...
2
by: Scirious | last post by:
People, I need a way to detect the moment an animated GIF gets to it's end to switch to a different GIF. I can't use a Timer because the GIFs have different times and doing so (as I'm doing at the...
3
by: ZikO | last post by:
Hi. I am making a Multimedia Presentation in VB.NET 2005 and I have some animated GIFs which I need to use. I tried to use PictureBox for it but it doesn't play an animation in GIFs :/. What I...
27
by: Phil | last post by:
I thought it would be nice to display some animated GIFs on some of my forms. I put a PictureBox control on a form, and loaded my GIF file in. It animates, but not properly. It seems very jerky and...
0
by: helraizer1 | last post by:
Hey, I have a PHP script that I made for an image based shoutbox with emoticons. The problem is that php GD doesn't support animated gifs, yet perl GD does. How would I make it so that I could...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.