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.
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.
No comments:
Post a Comment