I am having trouble in successfully caching (or pre-caching) an array of image objects
in Internet Explorer. I am loading a series of images for animation purposes. The
images are generated directly through the TestImage servlet by specifying
"res.setContentType("image/gif");" On the onload event of the HTML frame I am loading
the images to an array of image objects. This works perfectly in Netscape, so there
are no server roundtrips. But if I use IE it accesses the server constantly and reruns
the doGet() method of the servlet. Is there a way to prevent this from happening ? Or
am I doomed to the browser's mercy ?
FYI, previously the servlet was creating a series of GIF files on the server and the
script was reading them into the image objects. In that scenario IE was able to cache
the images successfully. My goal is to accomplish the same when the image.src is a
servlet URL.
I am including the frame source for your perusal.
Thanks
-Selim Tuvi
Rockwell Science Center
Palo Alto, CA
<HTML>
<HEAD>
<META http-equiv="pragma" content="no-cache">
<META http-equiv="expires" content="10-JAN-1980">
<style type="text/css">
#encap {position:relative; visibility:visible}
#img1 {position:absolute; visibility:visible; z-index:2}
</style>
<SCRIPT LANGUAGE="JavaScript">
var isNav, isIE
if (parseInt(navigator.appVersion) >= 4) {
if (navigator.appName == "Netscape") {
isNav = true
} else {
isIE = true
}
}
var images = new Array(23)
var currentImage = 0
var animation_on = false
var time_index
function preCache() {
for (i= 0 ; i < images.length ; i++) {
images[i] = new Image(320,360)
images[i].src
="/servlet/awareServlet.TestImage?timeIndex="+(images.length-i-1)+"&x=1434&y=1087"
}
}
function loadImage(imgNum) {
if (isIE)
document.images[0].src = images[imgNum].src;
else
document.encap.document.img1.document.images[0].src = images[imgNum].src;
}
function nextImage() {
if (animation_on) {
if (currentImage < images.length - 1) {
currentImage++;
} else {
currentImage = 0;
}
loadImage(currentImage);
}
}
function stop() {
animation_on = false;
}
function goBack() {
parent.document.location.href = '/servlet/awareServlet.WxBrowse';
}
</SCRIPT>
</HEAD>
<BODY bgcolor="#C0C0C0" onLoad="preCache(); loadImage(0)">
<form>
<table border=3 cellspacing=0 cellpadding=0>
<tr>
<td>
<div id="encap">
<span id="img1">
<img width=320 height=360 VSPACE=0 HSPACE=0 ALIGN=middle
onError="setTimeout('nextImage()',100)" onLoad="setTimeout('nextImage()',100)">
</span>
<img id="bground" src="/servlet/awareServlet.OverlayImage?x=1434&y=1087"
width=320 height=360>
</div>
</td>
</tr>
</table>
<table>
<tr><td width=100></td><td>
<input type="button" onClick="animation_on = true; nextImage()" value=">>">
<input type="button" onClick="stop()" value="Stop">
</td></tr></table>
<br><br><br>
<input type="button" onClick="goBack()" name="back" value="Back">
</form>
</BODY>
</HTML>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html