I want my website to have an overlay over the entire webpage and an GIF-animated "loading..." spinner whenever buttons (links and submit buttons) within my website are clicked. The website should work as an iPhone web app ("save to home screen") - therefore, I need the "window.location" (see Oskars comment). I do not and will not use any third party libraries (no jquery etc.).
What does work:
- Overlay works for all buttons
- Overlay and GIF animation work for form submit buttons
- The GIF does appear when I click a link, but...
What does not work:
- the GIF is not animated when a link is clicked. I am using Firefox, Internet Explorer and Chrome in their respective latest versions. All I find through google is references to "old" evil ie versions - but that is not the case here.
My question for you:
- How can I get the GIF to be animated?
For the time being, I will believe this comment and shut up...
Here's what I have in HTML and javascript:
<div id="overlay"></div>
<div id="page">
<a onclick="document.getElementById('overlay').style.display = 'block';
window.location='/';
return false;"
href="/"
title="home"
alt="home">
home
</a>
</div>
Here's what I have in CSS:
div#page {
position:absolute;
top: 0px;
left: 0px;
width:100%;
}
div#overlay {
display: none;
z-index: 10000;
background: #000;
position: fixed;
width: 100%;
opacity: .6;
height: 100%;
top: 0px;
left: 0px;
background-image:url("spinner.gif");
background-repeat:no-repeat;
background-position:center;
}
(where "spinner.gif" can be http://www.melabev.org/images/spinner.gif, for example)
Here's a jsfiddle version: http://jsfiddle.net/87paH/2/