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

161
Views
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 answers
Answer question

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 Report
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!