Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
How would get/edit data from a text file?

I have a specific website where i would like to see how many views a certain page gets, with a text file being edited every time a person clicks on the page. I've tried doing this myself but it did not work out, I am not sure if i have done anything wrong here myself since i am still new to javascript.

var viewC = FileReader.readAsText('./views.txt');

var views = viewC + 1
var viewFile = " " + views +" ";

function download(content, fileName, contentType) {
    var a = document.createElement("a");
    var file = new Blob([content], {type: contentType});
    a.href = URL.createObjectURL(file);
    a.download = fileName;
    a.click();
}
download(viewFile, 'views.txt', 'text/plain');

For a more detailed description of what i would like to happen : "When the user goes to the page, the code will run and add a new value to the text file. The new value is +1 of the old value that is there." Expected result -
TXT file before
TXT file after a person views it 1
TXT file after the second view 1 2
Or if it is possible to remove the old number and add the new number

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!