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

157
Visualizações
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
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