# Javascript question - why does â€œwindow.loc ationâ€ not ensure my spinner.gif animation works?

**URL:** <https://www.ruby-forum.com/t/javascript-question-why-does-a-oewindow-loc-ationa-not-ensure-my-spinner-gif-animation-works/184059>\
**Category:** Rails\
**Created:** [February 24, 2010, 12:39pm UTC](https://www.ruby-forum.com/t/javascript-question-why-does-a-oewindow-loc-ationa-not-ensure-my-spinner-gif-animation-works/184059 "2010-02-24T12:39:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![greghauptmann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e5b9ba/32.png) [@greghauptmann](https://www.ruby-forum.com/u/greghauptmann)\
**Post date:** [February 24, 2010, 12:39pm UTC](https://www.ruby-forum.com/t/javascript-question-why-does-a-oewindow-loc-ationa-not-ensure-my-spinner-gif-animation-works/184059/1 "2010-02-24T12:39:14Z")

</div>

Hi,

It seems when I use “window.location” as a means to redirect to the  
API when my longer running transaction is does not ensure the  
animation for the spinner gif I have works. Any ideas how to fix this?  
ie. I see the gif ok but it not being animated. Is there another way  
in Javascript to force the redirect once the gif animation starts?  
What’s the easiest way in Rails to get a “spinner” being show for the  
initial spash page whilst it goes to the database to prepare the  
detail for the main page.

CSS:

#loading {  
width:100px;  
height: 100px;  
position: fixed;  
top: 50%;  
left: 50%;  
background:url(/images/ajax-loader.gif) no-repeat center #fff;  
text-align:center;  
padding:10px;  
font:normal 16px Tahoma, Geneva, sans-serif;

# border:1px solid #666;

margin-left: -50px;  
margin-top: -50px;  
z-index:2;  
overflow: auto;  
}

---

<div class="post-metadata">

**Author:** ![greghauptmann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e5b9ba/32.png) [@greghauptmann](https://www.ruby-forum.com/u/greghauptmann)\
**Post date:** [February 25, 2010, 7:23am UTC](https://www.ruby-forum.com/t/javascript-question-why-does-a-oewindow-loc-ationa-not-ensure-my-spinner-gif-animation-works/184059/2 "2010-02-25T07:23:29Z")

</div>

In general I’ve found that only Internet Explorer (6, 7 & 8) has this  
problem, whereas  
other browsers such as Firefox and Safari are ok. In your case is the  
problem  
only with IE?

---

<div class="post-metadata">

**Author:** ![greghauptmann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e5b9ba/32.png) [@greghauptmann](https://www.ruby-forum.com/u/greghauptmann)\
**Post date:** [February 25, 2010, 7:27am UTC](https://www.ruby-forum.com/t/javascript-question-why-does-a-oewindow-loc-ationa-not-ensure-my-spinner-gif-animation-works/184059/3 "2010-02-25T07:27:01Z")

</div>

actually - I’ve had some advice towards a better option - now I’m  
using jQuery and doing:

$(‘body’).ajaxStart(function(){  
$(’#spinner’).show();  
});  
$(‘body’).ajaxStop(function(){  
$(’#spinner’).hide();  
});
