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>
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).