views:

416

answers:

2

** edit it seems that when the javascript changes the image that the reflection gets an undefined src. Any thoughts on that **

I've got this problem where I'm using jquery to reflect an image. I've got this news title list and it's automatically jumping through titles. Each time it changes the image and the reflection.

This works prefectly the first time but when you navigate back to the page it has cached the image so that it only shows the reflection of the first image for all images.

Does anyone know how to disable image caching?

I'm using reflection.js

This is the function that rotates between images.

function changeId(){
 $(".speglun").unreflect();
 if(id < 5){
  id++;
  var eldri = id - 1;
 }else{
  id = 1;
  var eldri = 5;
 }

 $('#newsBgW'+id).css("background-position", "-477px 0px");
 $('#newsBgW'+eldri).css("background-position", "0px 0px");

 $('#frettaMynd').attr("src", myndir[id]);
 $(".speglun").reflect();
 t = setTimeout("changeId()", time);
}
+2  A: 

When you build the URL for the image, add the current timestamp, so it looks sort of like image.jpg?20090305101423. This ought to prevent caching. Actually it will still cache, but a "different" image each time.

I answered this before you clarified. I have no idea about that jQuery plugin, but perhaps it still will be helpful..

Pawel Krakowiak
I've tried this and it doesn't work because I'm displaying it through a thumbgenerator. If the thumb has been generated it shows that image.
Belgurinn
A: 

to swap image use a jquery plugin, its very cool http://code.google.com/p/jquery-swapimage/

Haim Evgi
thank for the tip, I'll check this out.
Belgurinn