2

I want to generate a random number or string in HTML so that i add this to HTTP URL inside the HTML page to make it different each time page loads.

5 Answers 5

2

That's impossible. HTML is a markup language, and cannot be used for defining logic.

Sign up to request clarification or add additional context in comments.

Comments

1

You should use server side scripting language for that.

HTML does not provide random number generation without using javascript OR jQuery.

Comments

1

if you want to avoid cache problem insuring user has a different url each time he loads the page, you can do something like :

<body onLoad="location.hash = Math.floor((Math.random() * 100) + 1);">

2 Comments

yes i want to avoid cache problem but i cannot use javascript. I Think this will not work on the mobile phones those does not support javascript.
I would advise you to use meta tag then, but it doesn't seem a good idea. However, you have a solution here: stackoverflow.com/questions/6664542/…
0

I don't think that works, because HTML is a static language.

Comments

0

Something that uses php help? example :

<?php
$url ='https://linkexample/ws/'+ rand(1,100); + '.com';    
echo $url;
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.