Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

232
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!