I have an animated gif file that rotates when placed into an img element on a page. However, I want it to be hidden until I click a button on the page (while page is submitted). What I have tried is summarized below. When I click the button it does show
the gif but it is not animated. Also, when the DIV is displayed, the span does not show. How do I get it to spin until the page posts back?
This is a behavior In noticed once in IE (gif animations are stopped when submitting the form). If I remember I fixed that by using a setTimeout that just copy the src attribute to itself which launch again the animation shortly after the postback.
Edit: for the span try perhaps F12 in your browser to see if you don't have some unexpected CSS rules applied to this span.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
350 Points
1528 Posts
GIF not animated
Oct 06, 2016 05:30 PM|dlchase|LINK
I have an animated gif file that rotates when placed into an img element on a page. However, I want it to be hidden until I click a button on the page (while page is submitted). What I have tried is summarized below. When I click the button it does show the gif but it is not animated. Also, when the DIV is displayed, the span does not show. How do I get it to spin until the page posts back?
All-Star
48280 Points
17982 Posts
Re: GIF not animated
Oct 06, 2016 06:41 PM|PatriceSc|LINK
Hi,
This is a behavior In noticed once in IE (gif animations are stopped when submitting the form). If I remember I fixed that by using a setTimeout that just copy the src attribute to itself which launch again the animation shortly after the postback.
Edit: for the span try perhaps F12 in your browser to see if you don't have some unexpected CSS rules applied to this span.
Member
350 Points
1528 Posts
Re: GIF not animated
Oct 06, 2016 08:28 PM|dlchase|LINK
Yes, it works great in Chrome.
The span issue went away when I removed the <br /> element above it. Weird! Also, the F12 showed the break as <br><br /> and not sure why.
Star
9831 Points
3120 Posts
Re: GIF not animated
Oct 07, 2016 08:18 AM|Brando ZWZ|LINK
Hi dlchase,
As far as I know, when a postback occurs in Internet Explorer, it stops all animations on the page, as mentioned.
The trick to fixing this is to reload the animated gifs when the postback occurs.
More details, you could refer to follow codes:
Code-behind:
Best Regards,
Brando
Member
350 Points
1528 Posts
Re: GIF not animated
Oct 07, 2016 05:18 PM|dlchase|LINK
Thank you. Worked like a charm!