473,765 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.setTimeo ut 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 2116
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+newD ate()
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********@mai l.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+newD ate()

Jul 23 '05 #3

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

Similar topics

1
2918
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 available images for the start site. The site loads randomly an image or a Flash animation (if the flash plugin is present) through a javascript and each time the start site loades and displays only 1 different picture. At the moment the name of...
1
1425
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 adapt their source but without much luck. In my tests I would just like two pictures (test1.gif and test2.gif) to switch. I tried to assign these two to 'index_01' (see code below) which should be loaded on startup.
1
2444
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 have tied this animation to the single button on the page with the following piece of code: btn_rc.Attributes.Add("onClick", "status_change();") This works great. When I click the button, I get the animation, and when the page finishes the...
2
1470
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 called so it looks like an image and not an animation. I have decided to put a wait function that will pause for 3 sec so that the animation will be loaded then the call the function for the long process. This is the <SCRIPT> section
4
2454
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
3989
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. This works nice, but it is rather complex. I need to change it because it is made to display one camera, but I want more cameras on one page. With every change I make the refresh stops.
1
1705
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 I try to add the custom control to my other project, an error message pops up telling me the file could not be found. I placed the images being used in the same directory in each project, yet I still get this error. Does anyone have an idea on how I...
5
5353
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 finished item. The preview resides within a div and is simply a series of <br>-separated images. Simple html. The system is working fine with FireFox and Safari, but some MSIE 6 and 7 users are reporting that only the first image is updating and the...
1
5803
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 should delay my text updating by. Correct? When you mentioned a delay - is there an other way to do it than threads? I've found this solution.
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.