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

309
Visualizações
Access a JS file from a different directory

I have a project with the following structure:

project | -

  public | -
    -index.html
  src | -
    -index.js

and the code to import the file is :

<script src="../src/index.js"></script>

and it doesn't work. Any ideas why?

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

0

Assuming that public is the only directory exposed with a URL (i.e. you access index.html with http://example.com/index.html): you can't.

The browser can only access the file by requesting its URL, and if you've not put it in public then it doesn't have a URL.


Either:

  • Move the JS file
  • Configure the server to give it a URL via some mechanism other than it being inside the document root.
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