Click to See Complete Forum and Search --> : How to load a different page each time page refreshes?
Skuba
07-29-2003, 06:05 PM
Hi!
For a new site I am creating, I need to do one of the following options:
- Load a different home page each time user refreshes or enter site (I could be also just changing part of the code in the same page)
- Load different random different images on the home page as a slide show (BUT, it can't be just 1 image. I have a set of 5 images, that need to change to other 5 images).
Do you have any idea how to do eigther those?
It can be a javascript code, HTML, or PHP.
Thanks
David Harrison
07-30-2003, 01:49 PM
You could load a random home page every time by haveing an array of pages and then a redirect script like this:
var pages=new Array();
pages[0]="hi.html";
pages[1]="there.html";
window.location.href=pages[Math.round(Math.random()*(pages.length-1))];
And you could modify the attached script for your images.
Skuba
07-30-2003, 05:58 PM
THANKS!!!
David Harrison
08-04-2003, 01:52 PM
Happy to help. :)
vishalsood007
08-07-2006, 08:59 AM
Hi,
Saw your code for loading different pages each time the home page refreshes.
Somehow I am not able to do it as informed by you.
Can you please write the full code?
Thanks in advance.
Vishal Sood
drodax
10-14-2008, 10:56 AM
var pages=new Array();
pages[0]="hi.html";
pages[1]="there.html";
window.location.href=pages[Math.round(Math.random()*(pages.length-1))];
Hi,
this is interesting and i was able to make it work for me. But would you happen know if theres a way to somehow add a limit to how many times it redirects to the html pages? Example, everytime it randomly redirects to those 2 pages, and once each page has reach...lets say 5 reloads it will somehow timeout or redirect to another page? Is this easy to do?
thanks
rodd1000
10-15-2008, 10:53 AM
Hi, i have just tried this, but the page redirects over and over without refreshing, and doesnt allow time for the page to load, like on a loop (http://www.cnsdemo.co.uk/rot).
Click on the image.
Im pretty new to this, am i supposed to put
pages[0]="hi.html"; <------------------------------- this script in hi.html
pages[1]="there.html"; <------------------------------- this script in there.html
and not together?
Thanks