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

156
Vistas
Get the loading progress in JavaScript

So I'm thinking about making a gravatar link getter and I would like to add a loading screen but I don't know how to get loading progress with JavaScript when loading HTML and CSS assets

let loadingpercent = percent();

function LoadProj()
{
  document.write("Hold On, your request is loading.<br> " + loadingpercent);
}

function percent()
{
    //Code Goes here
    return NaN;
}
<input type="button" onClick="LoadProj()" value="LoadMe">

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can store the percent in a variable and the interval at which the progress should increment in another (in ms).

Then, in your LoadProj function, increment the percent and set the innerHTML of the body to the right value. Check if the percent is not 100. If it is not, we can use setTimeout to call LoadProj again with a delay, in our case, loadInterval. If it is, you know that it is finished loading, and you can handle it accordingly.

var percent = 0;
var loadInterval = 100;

function LoadProj() {
  percent++;
  document.body.innerHTML = "Hold On, your request is loading. " + percent;
  if (percent != 100) {
    setTimeout(LoadProj, loadInterval)
  }else{
    //Finished loading! Your code here...
    console.log('Finished loading!')
  }
}
<input type="button" onClick="LoadProj()" value="LoadMe">

about 4 years ago · Juan Pablo Isaza Denunciar
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