我無法嘗試刷新攝像頭圖像。第一張圖片加載正常,下面的圖片沒有加載。但是,在瀏覽器中刷新時,圖像會刷新,所以它應該只是java腳本的問題。在發佈我的問題之前,我嘗試了幾個腳本。我可以使這個腳本適用於其他靜態圖像,這導致我相信提供圖像的服務器以某種方式拒絕圖像刷新。最新的腳本是...使用Java腳本和/或jquery更新圖像
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<body>
<script type="text/javascript">
<!--
var refreshrate=1; //SECONDS BETWEEN REFRESH
var image="http://71.33.210.85/cam0.jpg"; //IMAGE NAME
var imgheight=240; //IMAGE HEIGHT
var imgwidth=320; //IMAGE WIDTH
function refresh(){
document.images["pic"].src=image+"?"+new Date();
setTimeout('refresh()', refreshrate*1000);}
document.write('<IMG SRC="'+image+'" ALT="Alternate Text" NAME="pic" ID="pic" WIDTH="'+imgwidth+'" HEIGHT="'+imgheight+'" STYLE="border: 1px solid Black;">');
if(document.images)window.onload=refresh;
// -->
</script>
</body>
</html>
我會不惜一切代價避免傳遞一個字符串setTimeout –
看看http://stackoverflow.com/questions/165253/javascript-how-to-force-image-not-to-use-the-browser-cache – RafH
也document.write頁面完成後執行ed加載將覆蓋頁面,或寫一個新的頁面,或不工作 - 不確定是否要每次覆蓋它或添加一個新的圖像 –