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

154
Views
I need to automate running a JavaScript function on a bunch of pages, can this be done?

I have a lot (think tens of thousands) of cfm files where I need to add a custom attribute to the HTML tags. I worked up a Javascript function that can update a single page. Can I open a file with Coldfusion, change it with Javascript, then save the changed file with Coldfusion? Can you do both of these with CFScript? Would I be better served to use Powershell? I think you open a cfm file in Powershell something like...

$file = 'C:\example.cfm'
$ie = New-Object -COM 'InternetExplorer.Application'
$ie.Navigate("file://$file")

And my Javascript function is...

var x = document.getElementsByClassName("ThisClass");
// Loop through ThisClass elements
for (i = 0; i < x.length; ++i) 
{
  // Get the string in the HTML
  var y = x[i].innerHTML;
  // Replace spaces with underscores
  var newstring = y.replace(' ', '_');
  // Add new attribute with spaceless value
  x[i].setAttribute('ThisAttribute', newstring);
}

But how would do the Javascript stuff on the $ie file in Powershell? And then save the edited file? Any help or direction would be appreciated.

about 4 years ago · Juan Pablo Isaza
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!