我现在能实现通过javascript读取txt的内容,但是我希望5秒刷新一次内容,我是用在gadget里的。

解决方案 »

  1.   

    要结合ajax 。
    最简单 jquery 
    $("#div").load("txt.txt");
      

  2.   

    <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>