Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
import environment variable inside html and javascript

I have a maven project with folders like myproject/src/main/resources/public. I am using this maven project just to make a war and deploy my UI code (containing HTML5, JavaScript(with jQuery), CSS etc) to tomcat server and nothing java related.

And inside public folder, I have index.html and builder.js files defined.

index.html which has the following line:

<button type="button" id = "bButton " onclick="location.href='https://myserver-dev.com/Builder/builder.html'">Builder</button>

And another JS file builder.js where I am setting env variable like this:

//  var envURL = "http://localhost:8080";
  var envURL = "https://myserver-dev.com";
  //var envURL = "https://myserver-test.com";

I was thinking of creating a separate JS file, maybe something like properties.js or env.js and put the following in it so that I can just import it in html and js files whenever needed:

//  var envURL = "http://localhost:8080";
  var envURL = "https://myserver-dev.com";
  //var envURL = "https://myserver-test.com";

If I do that what would be the best way to get the envURL inside index.html and builder.js at appropriate places?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda