Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Chit-Chat (http://www.chiefdelphi.com/forums/forumdisplay.php?f=14)
-   -   Random Page Loader (http://www.chiefdelphi.com/forums/showthread.php?t=29979)

coreyk 16-08-2004 13:03

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.

JohnBoucher 16-08-2004 15:32

Re: Random Page Loader
 
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. :)

Max Lobovsky 16-08-2004 16:37

Re: Random Page Loader
 
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.

rowe 16-08-2004 16:38

Re: Random Page Loader
 
im just making this on the fly, but i think the code would be:
Code:

<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.

coreyk 16-08-2004 18:58

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


All times are GMT -5. The time now is 07:38.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi