22 de febrero de 2013

JOOMLA: refrescar o actualizar una imagen automáticamente

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3.   <head>
  4.     <title>Mi webcam</title>
  5.   </head>
  6.   <body>
  7.     <img name="oImg" id="oImg" src="http://camaras.dominio.com/Camaras/oImg.jpg" width="800" height="600" border="0"/>
  8.     <script language="JavaScript" type="text/javascript" >
  9.         periodo = 1;  // segundos entre recargas
  10.         imgoImg=document.getElementById("oImg");
  11.         imgsrc = imgoImg.src;
  12.         buffer = new Image();
  13.         buffer.onload = imageChange;
  14.         buffer.onerror = imageError;
  15.         setTimeout("imageReload()", periodo * 1000);
  16.        
  17.         function imageReload() {
  18.             buffer.src = imgsrc + "?d=" + new Date().getTime();
  19.             setTimeout("imageReload()", periodo * 1000);
  20.         }
  21.        
  22.         function imageChange() {
  23.             imgoImg.src = buffer.src;
  24.         }
  25.      
  26.         function imageError() {
  27.             setTimeout("imageReload()", 1000);
  28.         }
  29.     </script>
  30.   </body>
  31. </html>

No hay comentarios:

Publicar un comentario