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

121
Visualizações
Give access of script only to specific id in the url

I have a JavaScript file and want to load it only to some specific ids to load in head. The domain when user is logged in is www.domain.com?id=122 And the script url is www.domain.com/script.js And I put the script with parameter in head of home page if user is logged in www.domain.com/script.js?id=122 And I get the id from the current url by split and some JavaScript stuff. Now the problem is what to add in the script file to make the script load only for some specific ids

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

0

Technically you can check the URL parameter, and create a script tag from code only if you are satisfied:

if(location.search === "?id=122") {
  let s = document.createElement("script");
  s.src = "script.js";
  document.head.append(s);
}

However it's not something what could be used for security purposes for example.

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