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

150
Visualizações
HTML doesn't load JS files

i try to make a simple website with external js and css files.

HTML:

<html>


<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <script src="../js/main.js"></script>
  <title> John Doe </title>
</head>

<body>

  <div>
    <p>Landing Page in Progress</p>
    <button onclick="clickAlert()">Test</button>
  </div>

</body>

</html>

JS:

function clickAlert() {
    alert("Test")
}

Folder structure:

folder_structure

But when i click the button i get the error "clickAlert is not defined". Everything is hosted on an Webserver running Ubuntu/Apache. I know that for this simple function i wouldn't need an external file but i want to expand the site more. Thanks for every help!

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You should put the js folder in the static folder then put the src as "js/main.js". If the javascript is not included in the static folder, the server doesn't know to put those files on the server.

about 4 years ago · Santiago Trujillo 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