Eponymouse
Programmer
All --
I’m a java programmer but a javascript newbie… Any help appreciated.
I’m putting together a quick site, currently at:
See the image in the middle of the page (a “mani wheel”)? When the wheel image is clicked on, I would like to do two things:
1. Replace the static wheel gif with an animated gif
2. call a java servlet
To do this, I have one solution that works in firefox, and another one that works in IE, but nothing that works in both. Here is the relevant code:
function spin() {
document.getElementById('staticwheel').src='mwspinning.gif';
document.getElementById('spuntext').style.visibility='hidden';
document.getElementById('totaltext').style.visibility='hidden';
SpinForm.submit();
}
which is called from this form:
<div Class=wheel>
<FORM NAME="SpinForm" ACTION="/ManiWheel" METHOD="POST">
<INPUT TYPE="hidden" NAME="spun" VALUE=true>
</FORM>
<img id="staticwheel" href="#" src="mwstatic2.gif" onclick="javascript:spin()"></img>
</div>
The above solution works for me in firefox, but not in IE. With this solution in IE, I don’t get the static image replaced with the animated one when it is clicked on.
Thinking that the problem might involve IE re-using a cached image rather than getting a modified one, I added a randomized parameter to the image link. This changes the javascript to:
function spin() {
document.getElementById('staticwheel').src='mwspinning.gif?spins=23232';
document.getElementById('spuntext').style.visibility='hidden';
document.getElementById('totaltext').style.visibility='hidden';
}
That change makes it work in IE, but makes it fail in firefox. Under this solution, the behavior changes in firefox so that you actually have to double-click on the image to make it spin, rather than single-click. This is sufficiently bizarre that I am appealing to you all for help.
Does anyone know how to do an onclick replace of a static image with an animated one, in a way that works in both IE and firefox?
Thanks,
Eponymouse
I’m a java programmer but a javascript newbie… Any help appreciated.
I’m putting together a quick site, currently at:
See the image in the middle of the page (a “mani wheel”)? When the wheel image is clicked on, I would like to do two things:
1. Replace the static wheel gif with an animated gif
2. call a java servlet
To do this, I have one solution that works in firefox, and another one that works in IE, but nothing that works in both. Here is the relevant code:
function spin() {
document.getElementById('staticwheel').src='mwspinning.gif';
document.getElementById('spuntext').style.visibility='hidden';
document.getElementById('totaltext').style.visibility='hidden';
SpinForm.submit();
}
which is called from this form:
<div Class=wheel>
<FORM NAME="SpinForm" ACTION="/ManiWheel" METHOD="POST">
<INPUT TYPE="hidden" NAME="spun" VALUE=true>
</FORM>
<img id="staticwheel" href="#" src="mwstatic2.gif" onclick="javascript:spin()"></img>
</div>
The above solution works for me in firefox, but not in IE. With this solution in IE, I don’t get the static image replaced with the animated one when it is clicked on.
Thinking that the problem might involve IE re-using a cached image rather than getting a modified one, I added a randomized parameter to the image link. This changes the javascript to:
function spin() {
document.getElementById('staticwheel').src='mwspinning.gif?spins=23232';
document.getElementById('spuntext').style.visibility='hidden';
document.getElementById('totaltext').style.visibility='hidden';
}
That change makes it work in IE, but makes it fail in firefox. Under this solution, the behavior changes in firefox so that you actually have to double-click on the image to make it spin, rather than single-click. This is sufficiently bizarre that I am appealing to you all for help.
Does anyone know how to do an onclick replace of a static image with an animated one, in a way that works in both IE and firefox?
Thanks,
Eponymouse