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

157
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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