Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q864 Is it possible to randomly load a page from a set of urls every 20 seconds?

You are here: irt.org | FAQ | JavaScript | Random | Q864 [ previous next ]

You can adapt the following script:

<html>
<head>
<script>
<!--
// The Central Randomizer 1.3 (C) 1997 by Paul Houle (houle@msc.cornell.edu)
// See:  http://www.msc.cornell.edu/~houle/javascript/randomizer.html

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function rand(number) {
        return Math.ceil(rnd()*number);
};

// end central randomizer. -->

</script>

<script language="JavaScript"><!--
var myArray = new Array();

var i = 0;

myArray[i++] = 'http://www.irt.org/';
myArray[i++] = 'http://www.yahoo.com/';
myArray[i++] = 'http://www.yahoo.com/';
myArray[i++] = 'http://www.netscape.com/';
myArray[i++] = 'http://www.microsoft.com/';
myArray[i++] = 'http://www.mozilla.org/';

function loadRandom() {
    window.frames[0].location.href = myArray[rand(i)-1];
    setTimeout("loadRandom()",20000);
}
//--></script>
</head>

<frameset rows="100%,*" onLoad="setTimeout("loadRandom()",20000)">
<frame src="initialpage.htm">
<frame src="blank.htm">
</frameset>

©2018 Martin Webb