PDA

View Full Version : random page load/refresh


cbennison
11-06-2003, 03:28 AM
have multiple versions of a simple goofy site
would like random loading of homepage on each visit
and on each refresh of only the index.htm page.

have tried a random redirect script such as the one
below, but does not allow for the random refreshing
of a certain page. any suggestions would be greatly
appreciated asap.

many thanks.


<script language="JavaScript"><!--
var item = 0;
var URL = new Array();

URL[item++] = '../../articles.htm';
URL[item++] = '../../index.htm';

function randomJump() {
var random = rand(item) - 1;
location.href = URL[random];
}
//--></script>

piglet
11-06-2003, 10:28 AM
Hi,

The redurect script will work find for the inital load - but will not cater for the reload.

For refresh to load a completely different page it is best done on the server.

Do you have perl/php/asp available to you on the server?

cbennison
11-07-2003, 01:56 AM
thanks the for quick response.
i have perl, php, and asp available on my server
however i'm pretty clueless - was just looking for
a quick solution to my problem. what would be
involved? i know my way around dreamweaver but
that's about it. have never gotten into any
scripting. any help would be totally apreciated.
but if i'm in over my head, just say so and i'll
look for another solution.

thanks!

piglet
11-07-2003, 04:11 AM
Hi,

"pretty clueless" shouldn't be a problem - php's a fantastic tool and is easy to learn.

If you delete index.html from your server and then upload this script as index.php....:

<?php
srand(time());
require ("page".(rand()%2).".foo");
?>

...it may be only 2 lines long - but this will randomly pick a file called page0.foo or page1.foo and use it as the homepage!

If you change the "2" to another number (say 9) it will pick a page between page0.foo and page8.foo to be the homepage.

All you need do then is to create your variations of home pages, and upload them as pagen.foo