Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

276
Visualizações
replacing HTML text with date from text file

I'm trying to Figure out how to replace HTML text using js code, the goal of it is the read a "1.txt" file with a name and replace the HTML text (Replace me!!) if anyone can help me and point me in the right direction.

here is what I have now

<body class="htmlNoPages">
  
<div id="main"><p>Replace me!!</p></div>

</body>
<script type="text/javascript" id="gwd-init-code">
    function load() {
      // var text = ('test 123')
      var file = new XMLHttpRequest();
        file.open(GET,'file:///d:/1.txt', true);
        file.responseType =Text;      
        file.onreadystatechange = function() {
        if (file.readyState === 4) { // Makes sure the document is ready to parse
          if (file.status === 200) { // Makes sure it's found the file
          text = file.responseText;
          }
        }
      }
let element = document.querySelector('#main');
element.innerHTML = text;  
}   
window.onLoad = load();

</script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I did it like this

var TxtFile = new XMLHttpRequest();
TxtFile.onreadystatechange = function () {
    var allText = "Uw browser is niet compatibel of u heeft uw java script disabeld staan";
    if (TxtFile.readyState === XMLHttpRequest.DONE && TxtFile.status == 200) {
        allText = TxtFile.responseText;
        allText = allText.split("\n").join("<br>");
    }

    document.getElementById('planning').innerHTML = allText;
}
TxtFile.open("GET", 'File location', true);
TxtFile.send(null);

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda