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

160
Visualizações
Nodered+external html with JavaScript function

I have an external report.html file which contain also JavaScript. This JavaScript has a lot of variables which contain a lot of values. (Mb in plain text) At the end is taken and render to the nice table. But I need take this variables out from the report.html to the Node-red and process them there.

I tried to load the file and print it out by but it did not do the JavaScript function inside.

Do I have somehow read the variable as an variable in node-red?

Of course I could do the parser and process through whole document and parse it manually but it is tuns of work in case it is possible to just load it somehow.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Given that your html is already loaded as string in msg.payload and your javascript code is bounded by <script> and </script> tags, you can first parse your html by:

var jsCode = msg.payload.split("<script>").pop().split("</script>")[0];

And then to run the code represented in jsCode string use eval() function:

eval(jsCode);

Your environment will act as it was written in editor and executed by you, so you should have access to all vars and functions declared in the inline js code.

Disclaimer

Actually it is not safe to use eval() SEE WHY, but for your case maybe it's the best solution.

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