<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>crunchlife: IE7's Inanimate GIF</title>
    <link>http://crunchlife.com/articles/2008/06/11/ie7s-inanimate-gif</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>IE7's Inanimate GIF</title>
      <description>&lt;p&gt;Animated GIFs are most often used as activity indicators in modern &lt;a
href="http://en.wikipedia.org/wiki/Ajax_(programming)"
target="_blank"&gt;AJAX (asynchronous JavaScript and XML)&lt;/a&gt; enabled
websites. I decided to use a &lt;a
href="http://en.wikipedia.org/wiki/Gif" target="_blank"&gt;GIF (Graphic
Interchange Format)&lt;/a&gt; from &lt;a href="http://www.ajaxload.info/"
target="_blank"&gt;ajaxload.info&lt;/a&gt; on an application that I&amp;#8217;ve been
developing at work. The application performs server-side
processing on files uploaded by employees. Processing time varies depending on the size of the file. Larger files take longer.&lt;/p&gt;

&lt;p&gt;I wanted the animated GIF to appear when the file upload button was clicked so I placed the image within a &lt;a href="http://www.w3schools.com/tags/tag_DIV.asp" target="_blank"&gt;DIV&lt;/a&gt; tag and hid it by setting a blank &lt;a href="http://www.w3schools.com/css/pr_class_display.asp" target="_blank"&gt;CSS display property&lt;/a&gt;. OnClick of the upload button, a
JavaScript function toggled the display value to &amp;#8220;block&amp;#8221;, making the DIV appear. This worked as
expected in &lt;a href="http://www.mozilla.com/en-US/firefox/?utm_id=Q108&amp;amp;utm_source=google&amp;amp;utm_medium=ppc&amp;amp;gclid=CPnY35q27JMCFQtvGgodcnzhWg" target="_blank"&gt;Firefox&lt;/a&gt; and IE6, but not in IE7. The DIV appeared in IE7,
but it&amp;#8217;s GIF wasn&amp;#8217;t moving.&lt;/p&gt;

&lt;p&gt;A little googling turned up a helpful comment on &lt;a href="http://west-wind.com/WebLog/default.aspx" target="_blank"&gt;Rick Strahl&amp;#8217;s blog&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
I&amp;#8217;ve run into a problem with animated gifs inside of a hidden area of a Web page that is hidden with style.display=&amp;#8217;none&amp;#8217;. When the area is made visible again, in Internet Explorer this causes the image to not be displayed an animated GIF whatever I try. [sic] 
&lt;/blockquote&gt;

&lt;p&gt;Apparently IE7 doesn&amp;#8217;t like to animate hidden GIFs. User submitted comments on Rick Strahl&amp;#8217;s blog provided many solutions, but only a couple worked in my situation. The first uses the JavaScript setTimeout method to populate the image&amp;#8217;s SRC attribute 200 ms after the function call. The second sets the DIV&amp;#8217;s innerHTML to a string containing an &lt;a href="http://www.w3schools.com/tags/tag_IMG.asp" target="_blank"&gt;IMG&lt;/a&gt; tag with the animated GIF.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;script language='javascript'&amp;gt; 
    function ShowLoading(elementId) 
    {
        document.getElementById(elementId).style.display = &amp;quot;block&amp;quot;; 
        setTimeout('document.images[&amp;quot;loadingImage&amp;quot;].src = &amp;quot;../images/loading.gif&amp;quot;', 200); 
    } 
&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Neither solution is ideal, but setting the element&amp;#8217;s innerHTML felt a little bit cleaner to me.&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;script language='javascript'&amp;gt;
    function ShowLoading(elementId)
    {   
        var element = document.getElementById(elementId);    

        element.innerHTML = &amp;quot;&amp;lt;img src='../images/loading.gif'&amp;gt;&amp;quot;;    
        element.style.display = &amp;quot;block&amp;quot;;
    }
&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;
*IE7 may have animations disabled. Go to Tools &gt; Internet Options &gt; Advanced &gt; Multimedia. Checking &amp;#8220;Play animations in webpages&amp;#8221; may affect how IE7 renders your animated GIFs.
&lt;/strong&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 11 Jun 2008 05:06:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:a2283586-36cd-4064-8291-8155c59f2cf9</guid>
      <author>Ryan Baxter</author>
      <link>http://crunchlife.com/articles/2008/06/11/ie7s-inanimate-gif</link>
      <category>Code Snippets</category>
      <category>Expect the Unexpected</category>
      <category>ASPNET</category>
      <category>JavaScript</category>
      <trackback:ping>http://crunchlife.com/articles/trackback/68</trackback:ping>
    </item>
    <item>
      <title>"IE7's Inanimate GIF" by Ryan </title>
      <description>Well times have changed but I'm having this problem too. The first solution works in Firefox but the image is still no moving in IE. The second solution seems to work in IE but not in Firefox.

fun...</description>
      <pubDate>Fri, 24 Dec 2010 10:39:40 -0800</pubDate>
      <guid isPermaLink="false">urn:uuid:24d0e3d8-8f2d-4cb7-ab99-09e2464182e1</guid>
      <link>http://crunchlife.com/articles/2008/06/11/ie7s-inanimate-gif#comment-115626</link>
    </item>
    <item>
      <title>"IE7's Inanimate GIF" by waynenort@hotmail.com</title>
      <description>Hello Ryan,

I'm stumped with the inanimate gif with uploading and are finding it hard to implement your solution. 
Would you mind having a look at my code..

//my current java:

function popup() {
document.getElementById('overlay').style.display='block';
document.getElementById('popup').style.display='block';
}


//my HTML, gif and button form:
	
	Please wait while we process your request...&lt;br /&gt;
    
	
    

//my CSS:
#overlay {
	display: none;
	position:absolute;
	top:0px;
	left:0px;
	width:100%;
	height:145%;
	background:#000;
	opacity:0.32;	-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=32)";
	filter:alpha(opacity=32);
	-moz-opacity:0.32;
	z-index:14;
}

#popup {
	display: none;
	position:absolute;
	top: 50%;
	left: 50%;
	height:150px;
	width: 300px;
	margin-left: -150px;
	text-align:center;
	border:1px solid #666666;
	z-index:15;
	background-color: #FFFFFF;
	padding-top: 50px;
}

many thanks,
Wayne</description>
      <pubDate>Sat, 08 Aug 2009 23:24:32 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:17b01124-3e52-49e3-9371-5c66604f35cc</guid>
      <link>http://crunchlife.com/articles/2008/06/11/ie7s-inanimate-gif#comment-28124</link>
    </item>
    <item>
      <title>"IE7's Inanimate GIF" by Ryan Baxter</title>
      <description>Awesome!  Glad this helped someone.</description>
      <pubDate>Mon, 06 Apr 2009 10:08:44 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:cd77c44c-dfa7-46d1-b9c0-e0210c492a82</guid>
      <link>http://crunchlife.com/articles/2008/06/11/ie7s-inanimate-gif#comment-26596</link>
    </item>
    <item>
      <title>"IE7's Inanimate GIF" by Steve</title>
      <description>Thanks Ryan - seems to have done the trick!</description>
      <pubDate>Mon, 06 Apr 2009 05:37:44 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:1727fa35-59c2-465a-ab6c-08d07049599c</guid>
      <link>http://crunchlife.com/articles/2008/06/11/ie7s-inanimate-gif#comment-26593</link>
    </item>
    <item>
      <title>"IE7's Inanimate GIF" by Hamish</title>
      <description>Thanks for this Ryan - your first solution solved my problem. </description>
      <pubDate>Thu, 02 Oct 2008 02:41:32 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:0227ff4e-d963-4682-97ef-baf7f69a401f</guid>
      <link>http://crunchlife.com/articles/2008/06/11/ie7s-inanimate-gif#comment-4800</link>
    </item>
    <item>
      <title>"IE7's Inanimate GIF" by Sanjay</title>
      <description>Hello Ryan,

 Thanks for your post. I tried both of the suggested methods but it wouldn't work for me. In my case, every time a request is made , a new Busybox object is displayed, with it a gif is associated. the gif refuses to animate when some process is taking place behind. Is there any other work around to make it animate?

thanks,
Sanjay</description>
      <pubDate>Sun, 07 Sep 2008 23:33:27 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:e83d4ede-97b4-409d-8c80-5164d63a12da</guid>
      <link>http://crunchlife.com/articles/2008/06/11/ie7s-inanimate-gif#comment-4611</link>
    </item>
  </channel>
</rss>

