Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda