<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Elliott C. Back &#187; Javascript</title>
	<atom:link href="http://elliottback.com/wp/category/computers-technology/code/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://elliottback.com/wp</link>
	<description>Internet &#38; Technology</description>
	<lastBuildDate>Mon, 26 Dec 2011 06:16:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Animated Gif Stops with Javascript / Click?</title>
		<link>http://elliottback.com/wp/animated-gif-stops-javascript-click/</link>
		<comments>http://elliottback.com/wp/animated-gif-stops-javascript-click/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 23:47:52 +0000</pubDate>
		<dc:creator>Elliott Back</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://elliottback.com/wp/?p=2840</guid>
		<description><![CDATA[If you&#8217;ve ever tried to get an animated .gif file to continue playing in IE after a link is clicked, javascript runs for a form submit, or the window.location is set to a new URL, then you&#8217;ve probably already gone through the phases of frustration, and come straight to Google.
Here&#8217;s the setup.  You&#8217;ve got [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever tried to get an animated .gif file to continue playing in IE after a link is clicked, javascript runs for a form submit, or the window.location is set to a new URL, then you&#8217;ve probably already gone through the phases of frustration, and come straight to Google.</p>
<p>Here&#8217;s the setup.  You&#8217;ve got a piece of javascript redirecting the user on a click (yes, I know this is a bad idea).  Hopefully you got this from a legacy app:</p>
<pre class="brush: js">&lt;script language="javascript"&gt;&lt;!--
function go(href) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$('spinner').style.display = '';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location.href = href;
}
//--&gt;&lt;/script&gt;
&lt;a href="defaultAction.htm" onClick="go(this.href);return false"&gt;go&lt;/a&gt;</pre>
<p>Internet Explorer stops animated gifs when there is a javascript event, so if you try this code, it&#8217;s going to fail dramatically.  What you need (for IE6 and IE7) is a hack:</p>
<pre class="brush: js">&lt;script language="javascript"&gt;&lt;!--
function go(href) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$('spinner').style.display = '';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location.href = href;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$('spinner').src = $('spinner').src;
}
//--&gt;&lt;/script&gt;
&lt;a href="defaultAction.htm" onClick="go(this.href);return false"&gt;go&lt;/a&gt;</pre>
<p>Yes, reassigning the src attribute of an img will cause the image to keep animating, even when in the process of loading the next page.  Note&#8211;this doesn&#8217;t work as well in Firefox.  For that, you should either (a) upgrade the application to load data through AJAX, not URL redirection, or (b) use an iframe pointing to the image.</p>
<p><small>PS, if you need some <a href="http://www.sanbaldo.com/wordpress/1/ajax_gif/">ajax loading indicators</a>, there&#8217;s a bunch!</small></p>
]]></content:encoded>
			<wfw:commentRss>http://elliottback.com/wp/animated-gif-stops-javascript-click/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.160 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-10 06:14:44 -->

