473,396 Members | 2,030 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,396 software developers and data experts.

automatic image reload?

JR
Is there a script available to automatically reload images on visiting
a page? I change images once a week and they have the same name so
I'm not changing the page code. Some people have the previous week's
image in their cache. I'd rather not put a message line on the page
asking the visitor to hit the refresh button nor use a code that
reloads the whole page unless reloding the page is an only option.

Thanks for your suggestions,

John
Jul 20 '05 #1
2 26255
Lee
JR said:

Is there a script available to automatically reload images on visiting
a page? I change images once a week and they have the same name so
I'm not changing the page code. Some people have the previous week's
image in their cache. I'd rather not put a message line on the page
asking the visitor to hit the refresh button nor use a code that
reloads the whole page unless reloding the page is an only option.


Append a unique "search" suffix to the src of each image.
You could do this as the page loads, but it's simpler to
do it after the load, as in this example:
<html>
<head>
<script type="text/javascript">
function refreshImages(){
var search="?"+(new Date()).getTime();
for(var i=0;i<document.images.length;document.images[i++].src+=search);
}
</script>
</head>
<body onload="refreshImages()">
<img src="http://www.azphx.com/dhtml/tmp/alpha6464.jpg">
<img src="http://www.azphx.com/dhtml/tmp/beta6464.jpg">
</body>
</html>

Jul 20 '05 #2
JR wrote:
Is there a script available to automatically reload images on visiting
a page? I change images once a week and they have the same name so
I'm not changing the page code.


Client-side JavaScript will not help you in general here: It can be
restricted, disabled or not even supported. You can define that
standards-compliant UAs should always re-download the document and its
linked resources from the original source (that should also exclude the
cache of proxy servers, you did not think about that):

<head>
...
<meta http-equiv="expires" content="0">
...
</head>

On the Web (using HTTP,) you can use the `Expires' HTTP header the same way.
See RFC 2616 for details.

Another way are cookies that store the date of last visit and if that was
more than a week ago, you force to reload with `location.reload(true)'. But
their storage may be seen as a violation of privacy.
PointedEars

Jul 20 '05 #3

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

Similar topics

0
by: Michael Huhn | last post by:
I have a web page default.aspx and a dynamic image image.aspx. Image gets parameters via querystring and outputs a gif. Using JavaScript I reload the image with changed parameters quite often....
1
by: Marco Maroni | last post by:
How to force image refresh on client browser ? Is ti possible to force the refresh of the same image (tha was changed server-side) to the client, without user press Contrl+F5 in IE ? - Marco
7
by: fh | last post by:
hello! I 've a found way to reload my page automatically every n seconde using this code Response.AppendHeader("Refresh", "4"); it works fine but I wish to do the same with only a part of my...
1
by: Chuck Anderson | last post by:
I'm using a simple, pseudo progress bar. Very simply, I display a still image next to a form submit button until the user clicks on it, and then I change the image source to an animated version of...
1
by: chris | last post by:
I am uploading a new image to my database. The upload works ok and the new image is stored ok on server. The problem is can I force a reload on cache to display the new image. If I reload the page...
9
by: andrewfelch | last post by:
Hello all, I'm using the metaclass trick for automatic reloading of class member functions, found at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/160164 My problem is that if I 1)...
32
by: C. (http://symcbean.blogspot.com/) | last post by:
Hi all, I have an application which generates image graphs. These cache nicely at the client, however if the user submits more data, I'd like to force a reload of the image from the server. I...
7
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to...
0
by: Alan Baljeu | last post by:
Alan Baljeu http://www.collaborative-systems.org Intelligent software that works _with_ you. ----- Forwarded Message ---- From: Alan Baljeu <alanbaljeu@yahoo.com> To: Mike Driscoll...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
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...
0
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,...
0
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...

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.