Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Aperture

macrumors 68000
Original poster
Mar 19, 2006
1,876
0
PA
Hi, I implemented a JavaScript code onto a .php file and made it my index on KevinSchaefer.net. The code is setup to redirect to a set of 3 URLs randomly, although it seems to favor one. I did 10 reloads, (Yes, going back to the index.php file ;) ) and 6/10 times it directed to this.. Sometimes it favors this. Sorry if this sounds insane, its kind of annoying. Is there a way to make it purely random? Here is the code im using:

Code:
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<script type="text/javascript">
      var pageArr = ["/home/1/index.html", "/home/2/index.html", "/home/3/index.html"];
		document.location.href = pageArr[Math.ceil(Math.random()*pageArr.length)-1];
	</script>

Any help appreciated.

Thanks, Kevin
 
You're only generating a random value of a set of three... the less items, the more chance you will have to continually land on the same generated number. Didn't you ever take statistics?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.