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

Q706 Is it possible to randomise the selection of sound files to be played?

You are here: irt.org | FAQ | JavaScript | Sound | Q706 [ previous next ]

Try:

<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>
</HEAD>
<BODY>

<SCRIPT LANGUAGE="JavaScript"><!--
document.write('<EMBED SRC="sound' + rand(9) + '.wav" HIDDEN=TRUE>');
//--></SCRIPT>

</BODY>
</HTML>

Which will play a random sound file sound1.htm to sound9.htm.

©2018 Martin Webb