473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

updating images in JavaScript animation

I am trying to make a JavaScript animation of real-time images - i.e.
images that will periodically change on the server. The problem I am
having is that the JavaScript animation I have created is always using
the images from the cache, even though I have set the HTTP response
header on the server (via .htaccess) so that the browser should
validate the image in the cache against the image on the server for
freshness. I have tested the HTTP response headers I am using and
they are working in other instances on the same server, so I am not
sure what I am doing wrong.

As to how my animation works, basically, I load a page with an image
on it and the image has an onLoad event handler that runs a JavaScript
function. The JavaScript function then figures out which image needs
to be displayed next, then does a preload on it (i.e. img=new Image;
img.src=imgSrc;) and then does a
window.setTimeout to change the src of the image
(i.e. document.images["img"].src=page;) in X seconds. I suspect that
what is happening is that the whole business of preloading the image
using JavaScript and changing the src of the image using JavaScript
doesn't involve making an actual request to the server, since I am not
reloading the page, and therefore the HTTP response headers I set on
the server aren't being applied.

My question is this: does anyone know of a general method for making a
JavaScript animation that will display the new versions of images
(same file names) when they have changed on the server?
Jul 23 '05 #1
2 2085
billrdio wrote:
I am trying to make a JavaScript animation of real-time images - i.e.
images that will periodically change on the server. The problem I am
having is that the JavaScript animation I have created is always using
the images from the cache, even though I have set the HTTP response
header on the server (via .htaccess) so that the browser should
validate the image in the cache against the image on the server for
freshness.


path = 'www.www.ww/img.gif'
myImage = new Image(100,100);
myImage.src =path + '?' + Mat.random+newDate()
Jul 23 '05 #2
Unfortunately, I already tried something like this. It works, but it
causes the browser to progressively use up more and more memory and
become unstable. At least with Netscape 7.1 on XP. I was testing
this with a 3 image animation that took only 20 seconds or so to go
through an entire loop, and after a few minutes, the browser locked
up. Maybe that isn't a fair test due to the shortness of the loop,
but what I think I need to do is force the browser to check the image
in the cache against the image on the server and replace the image in
the cache with the image on the server if it is newer - the HTTP
response headers that I have tried make this happen, but only if you
are reloading the page - they don't seem to have any effect if you are
preloading the image via JavaScript and then changing the src
attribute of the image to the next image in the loop via JavaScript.
Appending a "?string" to the end of the image file name will force the
browser to preload a new image, but then it will never use it's cache
and will continue to load "new" images everytime - I want it to use
images from the cache if they are still "fresh".

Marek Mänd <ca********@mail.ee> wrote in message news:<2u*************@uni-berlin.de>...
billrdio wrote:
I am trying to make a JavaScript animation of real-time images - i.e.
images that will periodically change on the server. The problem I am
having is that the JavaScript animation I have created is always using
the images from the cache, even though I have set the HTTP response
header on the server (via .htaccess) so that the browser should
validate the image in the cache against the image on the server for
freshness.


path = 'www.www.ww/img.gif'
myImage = new Image(100,100);
myImage.src =path + '?' + Mat.random+newDate()

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John | last post by:
Hi, we have the following problem: in our application v1.0 we have static html pages (+ some javascript). With a CMS (a Content Management System) some "mortal" people can add or expand the...
1
by: Alan Searle | last post by:
I am a newby to javascript and would like to have a section on one page where pictures change every 5 seconds. I found some example sites which do what I want and I have tried to 'borrow' and...
1
by: Scott | last post by:
I have an asp.net page that performs a function for a user that can take up to 30 seconds. So, I have a javascript function that shows an animation to let the user know something is going on. I...
2
by: Chris | last post by:
Hi, I have a Javascript function that loads a page with a progress bar for long process. The progress bar is a gif animation and for some reason it the animation is stuck when the function is...
4
by: Lando | last post by:
Can javascript build animated .gif or .jpeg ....I mean files *gif or *.jpeg that show animated images when are opened ( or is it another language that do it ? ) ? Thanks a lot.
2
by: JD | last post by:
Hello, I have webcams, and I want to display the images (jpg) from the cameras on a webpage, refreshed continuously. For a smooth transition I found a script that utilises double buffering....
1
by: TrueEmpath | last post by:
I'm trying to create a simple custom control that displays an animation composed of separate image files. However, I'm having trouble with how exactly I use the imported images with the control. When...
5
by: rosaryshop | last post by:
I'm working a jewelry/rosary design web site at http://www.rosaryshop.com/rosariesAndKits2.php. As the user makes selections, it updates images of various parts, giving them a preview of the...
1
by: K Viltersten | last post by:
> bar.PerformStep (); I noticed that there's a property for the bar stating what time it should take for the animation to move the fill to the requested spot. I'm guessing that's the time i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.