2012-12-17 54 views
0

我的攝像頭每10秒將圖像上傳到我的網站,並命名爲live.jpg ...我正在尋找一種方法來每10秒刷新一次圖像(以顯示最新的圖像),但圖像緩存,而不是更新。這裏是我使用的舊的JavaScript不工作....是否有一個簡單的修改,可以對它進行緩存圖像?非常感謝您的任何建議:javascript幻燈片,不會緩存圖像的攝像頭

<script type="text/javascript"> 
// (C) 2000 www.CodeLifter.com 
// http://www.codelifter.com 
// Free for all users, but leave in this header 
// NS4-6,IE4-6 
// Fade effect only in IE; degrades gracefully 

// ======================================= 
// set the following variables 
// ======================================= 

// Set slideShowSpeed (milliseconds) 
var slideShowSpeed = 10000 

// Duration of crossfade (seconds) 
var crossFadeDuration = 1 

// Specify the image files 
var Pic = new Array() // don't touch this 
// to add more images, just continue 
// the pattern, adding to the array below 

Pic[0] = 'http://www.examplesite.com/live.jpg' 

// ======================================= 
// do not edit anything below this line 
// ======================================= 

var t 
var j = 0 
var p = Pic.length 

var preLoad = new Array() 
for (i = 0; i < p; i++){ 
    preLoad[i] = new Image() 
    preLoad[i].src = Pic[i] 
} 

function runSlideShow(){ 
    if (document.all){ 
     document.images.SlideShow.style.filter="blendTrans(duration=2)" 
     document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)" 
     document.images.SlideShow.filters.blendTrans.Apply() 
    } 
    document.images.SlideShow.src = preLoad[j].src 
    if (document.all){ 
     document.images.SlideShow.filters.blendTrans.Play() 
    } 
    j = j + 1 
    if (j > (p-1)) j=0 
    t = setTimeout('runSlideShow()', slideShowSpeed) 
} 
</script> 

回答

3

向圖片網址添加一個變化的參數,例如:時間戳:

document.images.SlideShow.src = preLoad[j].src+'?'+new Date().getTime(); 
+0

的俗稱爲緩存無效 –

+0

感謝這麼多的源泉!很棒! – Wes

0

我想你應該緩存圖像預緊力與時間戳,而不是添加時間戳到幻燈片