Posted by : Deepak Vasudevan Wednesday, October 08, 2008

The Most Quickest and Easiest Way to generate random numbers with JavaScript

When we use XmlHttp Calls and dynamic images we should ensure that the web browser does not cache the resources. Towards this, we resort to having the URLs to be unique. To achieve this end, we need to have some kind of random content to be appended to the URL to make the browser feel that the particular resource URL is unique.

This is achieved in JavaScript by a quick and simple call to Math.Random(); method.

<Script>
alert (Math.Random());
</Script>

Keep executing the above function continously. At least to a significant extent, you should be getting unique numbers each time and this number you can try appending as a querystring in the URL to make it unique.

Popular Post

Blogger templates

Labels

Blog Archive

Followers

Blog Archive

Powered by Blogger.

- Copyright © Lavanya Deepak -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -