12million
12-23-2004, 11:03 PM
I'd like to have my splash page cycle through several (10 or more) different variations. I know how to cycle a single image on a static page already. That's not what I'm looking for.
Does anyone know of a script that has been written that can rotate entire splash pages automatically and randomly with each reload?
sonicgroup
12-23-2004, 11:09 PM
Depends on what kind of a solution you are after, and how you have your splash pages arranged.
Assuming they are the same filename with different numbers attached (splash1-10.html for my example):
In Javascript:
var num = rand(10);
document.location = "splash"+num+".html";
In PHP:
$num = rand(1, 10);
// then either include() the file, or use the header() function to redirect
include('splash'.$num.'.html');
// OR
header('Location: splash'.$num.'.html');
baboon1000
12-25-2004, 06:57 PM
<?
// Change this to the total number of images in the folder
$total = "11";
// Change to the type of files to use ex. .jpg or .gif
$file_type = ".jpg";
// Change to the location of the folder containing the images
$image_folder = "images/random";
$start = "1";
$random = mt_rand($start, $total);
$image_name = $random . $file_type;
echo "<img src=\"$image_folder/$image_name\"
alt=\"$image_name\" />";
?>
and just make that a file and include it where you want the images to rotate