Click to See Complete Forum and Search --> : Auto refresh with random page


GurusGuru
08-21-2003, 11:40 PM
Need a script that can auto refresh a page in the same frame say after x seconds with a random page/url from a list of pre defined pages/urls.

Charles
08-22-2003, 05:09 AM
<script type="text/javascript">
<!--
Array.prototype.random = function () {return this[Math.floor(Math.random() * this.length)]}

Date.ONE_SECOND = 1000;

url = ['fee.html', 'fie.html', 'foe.html', 'fum.html']

setTimeout('location = url.random()', 5 * Date.ONE_SECOND)
// -->
</script>

It will not work for those who do not use JavaScript so you'll need to provide links to those pages as well.

GurusGuru
08-29-2003, 01:31 AM
This script works fine and opens a random page.
How can I auto refresh a page (random) in a page using IFRAME?

Charles
08-29-2003, 06:51 AM
<script type="text/javascript">
<!--
Array.prototype.random = function () {return this[Math.floor(Math.random() * this.length)]}

Date.ONE_SECOND = 1000;

url = ['fee.html', 'fie.html', 'foe.html', 'fum.html']

setTimeout('iframeName.location = url.random()', 5 * Date.ONE_SECOND)
// -->
</script>