Random Page Loader

Does anyone know of a script or HTML code that will cause a random page to be displayed from a list each time the page is accessed?

Thanks.

Do you just want an different image to be displayed every time that page is loaded, or do you want a different .HTML page loaded?

The different image is easy, I don’t know if you can do a different page.

Check out www.team237.com for the random image loader. :slight_smile:

If you can use perl/cgi, php, jsp, etc, it should be very easy. Either hardcode an array with each element being the name of a file to be randomly selected, or dynamically create the array by making a list of all the files in a Database or directory. Then just use a random number generating function to select an element from the array and insert the contents of the file into the page. I can show you how to do it in PHP and others here know perl/cgi.

im just making this on the fly, but i think the code would be:


<script type="text/javascript">
<!--
var pages = new Array('url1','url2',...,'urlN');
function loadRandomPage(){
  var newPage = pages[Math.floor(Math.random()*pages.length)]
  window.location=newPage;
}
//-->
</script>
<input type="button" onclick="loadRandomPage()" value="Change URL">

Let me know if that works.

Thank you Eric, the script works! Thank you also to everyone who posted-- your help is greatly appreciated.