<html>
<head>
  <script type="text/javascript">
  <!--
  function ReadFile(filespec){  
  var fso = new ActiveXObject("Scripting.FileSystemObject");
  var file = fso.OpenTextFile(filespec);
  var text = file.ReadLine();
  file.Close();
  document.write(text);
  }
function ReadAll()
{
ReadFile('D:\\dTemp.txt');
document.write("<br>");
ReadFile('D:\\dPres.txt');
document.write("<br>");
ReadFile('D:\\dHum.txt');
document.write("<br>");
ReadFile('D:\\dLum.txt');
}
  -->
  </script>
</head>
<body>
  <table border="1" align= "left" background="c.jpg">
  <tr>
<td>
<table border="1" align= "left">
<tr>
<td>Température
<br>
Pression
<br>
Humidity
<br>
Luminosité</td>
</tr>
</table>
</td>
<td>
  <table border="1" align= "right">
<table>
<tr>
<td>
<script type="text/javascript" language="javascript">
//下面的数据就是我想实时读的,能不能帮忙改一改   
  ReadFile('D:\\dTemp.txt');
document.write("<br>");
ReadFile('D:\\dPres.txt');
document.write("<br>");
ReadFile('D:\\dHum.txt');
document.write("<br>");
ReadFile('D:\\dLum.txt');
  
</script></td>
</tr>
</td>
  </tr>
</table>
</body>
</html>

解决方案 »

  1.   

    定时的话用定时器
    setTimeout(function(){
       //dosomething
    }, 1000);
    不就行了?
      

  2.   

    你不觉得用ajax更方便吗???
      

  3.   

    还有用settimeout的话,只有第一次会刷新,之后就不刷新了,而且是整个窗口刷新,我的表格也不在了
      

  4.   

    挺简单的一个实例,上网搜索。。
    还有用setInterval
      

  5.   

    对啊,我用网上的实例都挺好用,但是我这里就不行,我是这样用的
    function ReadAll()

      ReadFile('D:\\dTemp.txt');
    document.write("<br>");
    ReadFile('D:\\dPres.txt');
    document.write("<br>");
    ReadFile('D:\\dHum.txt');
    document.write("<br>");
    ReadFile('D:\\dLum.txt');
    setTimeout(function(){Read()},1000);
      }   
    ReadAll();
    但是一刷新就表格什么的都没了,而且只有第一秒刷新,后就不动了。