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

100
Vistas
Reloading Page using javascript but updating original body HTML

Is it possible to reload a page in javascript but update the original HTML defined in the body tag? An example is below:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
</head>
<script language="javascript" type="text/javascript">
    window.onload = function(){  
        document.getElementById("button").addEventListener('click', () => {
        document.body.innerHTML = `<h1> ${Math.floor(Math.random() * 99999)}`;
        location.reload()
    });
    }
</script>
<body>
    <h1>Hehe</h1>
    <button id = "button">Reset</button>
</body>
</html>

The above will change the original body tag to a random number when "button" is clicked on and as expected, the body tag will revert back to its original state after refreshing (though it will briefly show the updated state before refreshing).

Is it possible to have the body html remain different even after "refresh" is called?

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