HTML:元标记没有刷新图像

时间:2014-01-12 06:10:32

标签: html html5

我使用以下html5代码显示带有图像的html页面(1.JPG)。它的工作正常。图像将在提供的相同路径中以特定间隔中的另一个较新图像随机覆盖。因此,我使用元标记刷新页面,这样无论何时在路径中覆盖任何较新的图像,页面都将自动刷新更新的图像。但是,看起来每隔5秒刷新页面就好了,但是它不显示在同一路径中覆盖的新图像,它始终显示我保留的初始图像。有人可以帮我解决这个问题吗?

<!DOCTYPE HTML>
<html>
  <head>   
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
    </style>
    <meta http-equiv="refresh" content="5">
  </head>
  <body>
    <canvas id="myCanvas" width="578" height="100"></canvas>
    <script>
      var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');

      context.font = 'italic 30pt Calibri';
      context.fillText('Screen sharing', 10, 50);
    </script>
    <p><img src = "file:////Users/Martin/Downloads/1.JPG" /> </p>
  </body>
</html>

1 个答案:

答案 0 :(得分:1)

元标记刷新网址,请尝试

<meta http-equiv="refresh" content="5; ,URL=http://domain.com">

或者您可以从javascript

执行此操作
<script type="text/javascript"> 
    setInterval(function(){
       window.location.reload();
    },5000); 
</script>

请使用SERVER网址加载图片而不是文件网址

<p><img src = "file:////Users/Martin/Downloads/1.JPG" /> </p>

更改为

<p><img src = "http://domain.com/Downloads/1.JPG" /> </p>