questo è il codice della pagina in questione...ogni 20 secs carica una nuova immagine dal server ma vorrei che l'ultima immagine prendo sia visibile (prenda il posto della precedente) solo quando è stata caricata completamente:
codice:
<html>
<head>
<title>::NaioSPy::</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<script language="javascript1.2" type="text/javascript">
<!--
function prendiElementoDaId(id_elemento) {
var elemento;
if(document.getElementById)
elemento = document.getElementById(id_elemento);
else
elemento = document.all[id_elemento];
return elemento;
};
function LoadXMLDoc(url) {
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
isIE = true;
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
};
function processReqChange() {
// only if req shows "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
// ...processing statements go here...
prendiElementoDaId('naietto').innerHTML = req.responseText;
} else {
alert(req.statusText);
}
}
};
function LoadIMG() {
url = "naiospy.cgi?action=newimage";
LoadXMLDoc(url);
};
function MainStart() {
LoadIMG();
window.setInterval('LoadIMG()', 20000);
}
//-->
</script>
<style type="text/css">
<!--
body {
margin: 5px;
padding: 5px;
background: #ccc;
}
a {
color: blue;
font: 15px Arial;
}
a:visited {
color: blue;
}
a:hover {
color: red;
}
div#naietto {
width: 800px;
height: 600px;
background: #eee;
border: 1px dashed #333;
padding: 5px;
margin: 10px;
}
h2 {
border: 1px dashed yellow;
background: #999;
padding: 5px;
}
div#navbar {
font: 13px Verdana;
}
//-->
</style>
</head>
<body onLoad="MainStart();">
<div id="navbar">
Index
<h2>::NaioSPy::</h2>
<div align="center">
!!! LIVE !!! From: claudio [127.0.0.1]</p></div>
</div>
<div align="center">
<div id="naietto"></div>
</div>
</body>
</html>