Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9114327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:10:33+00:00 2026-06-17T04:10:33+00:00

Okay, so I have a program which outputs some specific data to a tab

  • 0

Okay, so I have a program which outputs some specific data to a tab separated variable file.

I had been using Excel to open and view the file contents, however I found excel’s insistence on locking every file it opens to be incredibly annoying as my program would crash if I left the file open in Excel… but I would really like the data to neatly update after each run of the program, so I don’t have to close and re-open the file all the time.

So, I decided it would be easiest to use Javascript to parse the file and display it in a html table, and it was. I knocked something together in no time. Now my program doesn’t crash if I leave the file on display, however, it still doesn’t update… and I have to open the newly generated file each time.

So, I was wondering if there was a mechanism by which my Javascript could be somehow notified of a change to the file by another process? I know this is unlikely, but I would like to avoid simply polling the file for obvious reasons.

I am very familiar with JS, but HTML5 and the new APIs are all new to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:10:34+00:00Added an answer on June 17, 2026 at 4:10 am

    I don’t believe the File API has any event for the file changing, just progress events and the like.

    Update August 2020: The alternative below no longer works, and the specification specifically disallows it by saying that the File object’s information must reflect the state of the underlying file as of when it was selected. From the spec:

    User agents should endeavor to have a File object’s snapshot state set to the state of the underlying storage on disk at the time the reference is taken. If the file is modified on disk following the time a reference has been taken, the File’s snapshot state will differ from the state of the underlying storage.


    You could use polling. Remember the lastModifiedDate of the File, and then when your polling function fires, get a new File instance for the input and see if the lastModifiedDate has changed.

    This works for me on Chrome, for instance: Live Copy | Source

    (function() {
      var input;
      var lastMod;
    
      document.getElementById('btnStart').onclick = function() {
        startWatching();
      };
        function startWatching() {
            var file;
    
            if (typeof window.FileReader !== 'function') {
                display("The file API isn't supported on this browser yet.");
                return;
            }
    
            input = document.getElementById('filename');
            if (!input) {
                display("Um, couldn't find the filename element.");
            }
            else if (!input.files) {
                display("This browser doesn't seem to support the `files` property of file inputs.");
            }
            else if (!input.files[0]) {
                display("Please select a file before clicking 'Show Size'");
            }
            else {
                file = input.files[0];
          lastMod = file.lastModifiedDate;
                display("Last modified date: " + lastMod);
          display("Change the file");
          setInterval(tick, 250);
            }
        }
    
      function tick() {
        var file = input.files && input.files[0];
        if (file && lastMod && file.lastModifiedDate.getTime() !== lastMod.getTime()) {
          lastMod = file.lastModifiedDate;
                display("File changed: " + lastMod);
        }
      }
    
      function display(msg) {
        var p = document.createElement('p');
        p.innerHTML = msg;
        document.body.appendChild(p);
      }
    })();
    <input type='file' id='filename'>
    <input type='button' id='btnStart' value='Start'>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I have a function which reads a xml file and creates controls using
Okay, so I have a Flash CS3 (+ AS3) program which is loading another
Okay, I got this small program which tags (as in ID3v2.4 etc.) some music
Okay, so I have a little assignment to do which needs some array of
Okay. I have completed my first python program.It has around 1000 lines of code.
okay i have been trying to understand this for hours i am learning VB
Okay I have a series of objects based on a base class which are
Okay here's the program I have typed up(stdio.h is included also): /* function main
I have implemented a multi-threaded program which involves spawning a thread for each user,and
i have the following problem. The 1st step is to implement a program, which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.