Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q467 Is there some way to load a different home page each time someone comes to the site, or cycle through several different versions?

irt.org | Knowledge Base | JavaScript | Random | Q467 [ previous next ]

Q467 Is there some way to load a different home page each time someone comes to the site, or cycle through several different versions?

It would be possible to store a number in a cookie that would indicate to a user that later returns to display a different page - although not everyone accepts cookies. An easier approach would be to show a page depending on the time of day. The following assumes that there are pages index1.html through to index24.html

<SCRIPT LANGUAGE="JavaScript"><!--
var now = new Date();
var hour = now.getHours() + 1;

if (document.images)
    location.replace('http://www.somewhere.com/index' + hour + '.html');
else
    location.href = 'index' + hour + '.html';
//--></SCRIPT>

Note: in Opera replace() will work, but only with absolute URL's.


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.