I have a navigation bar and I want to access a random URL from a distinct list associated with each link. Link A would access List A, link B would access List B, and so on. I have been using a javascript code from 1997 that works great for one link:
<--code contained in a js file:-->
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);
};
var item = 0;
var URL = new Array();
URL[item++] = 'listitema.php';
URL[item++] = 'listitemb.php.php';
URL[item++] = 'listitemc.php';
function randomJump() {
var random = rand(item) - 1;
location.href = URL[random];
};
<--end js file:-->
This is accessed with this:
<a href="javascript:randomJump()" onmouseover="self.status='';return true">
While this code works well for one link per page, I now need to have it work for multiple links, each with a different reference list. I have no idea how to make this a script that works for each link without interfering with other links. Thank you.
Math.random()instead of your own function? Usually using a custom RNG makes only sense if you need to ensure that your local random values are the same as on the server (i.e. same algorithm, same seed)...