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

241
Vistas
Difficulty putting a javascript code in a refresh of an html page

I would like to add this random code in an HTML refresh. Once the refresh is triggered, it generates a random sequence and adds to the testing123 link.

<html>
  <body>
    <script type="text/javascript">
      function generateRandomString(n) {
        let randomString = '';
        let characters =
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

        for (let i = 0; i < n; i++) {
          randomString += characters.charAt(
            Math.floor(Math.random() * characters.length)
          );
        }
        return randomString;
      }
    </script>

    <meta
      http-equiv="refresh"
      content="1; URL='https://testing1234.serveirc.com/view.php?id="
    />
    <script type="text/javascript">
      generateRandomString(25);
    </script>
  </body>
</html>

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

0

If you're going to generate the random part of the URL client-side with JavaScript, it would make more sense to perform the redirect with JavaScript than to construct a <meta> tag for it.

<script>
function generateRandomString(n) {
    let randomString     = '';
    let characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    for ( let i = 0; i < n; i++ ) {
      randomString += characters[Math.floor(Math.random()*characters.length)];
   }
   return randomString;
}
setTimeout(() => {
  window.location.href = `https://testing1234.serveirc.com/view.php?id=${generateRandomString(25)}`;
}, 1000); // Redirect after 1 second
</script>

Using a meta tag makes more sense if you can construct the random part from server-side code that constructs the HTML (such as with PHP or Handlebars or some scripting template engine).

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