random index page

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

ckaas

Thread Starter
Joined
Feb 3, 2003
Messages
133
hello all, i was wondering how one sets up a website so that the index page is different everytime it loads? some sites like starwars.com use this, the index page is different everytime one reloads the page. how do one do this? :) thanks
 

ckaas

Thread Starter
Joined
Feb 3, 2003
Messages
133
yeah i notice the javascript, but could you point out at what point it determines what set of images are to be loaded, i'm a bit slow you see, for these things... thanks.
 
Joined
Jul 8, 2002
Messages
14,681
Its not a different page, just a random image Javascript.
Search at Javascriptsource.com theres like 2 dozen scripts for this.
 
Joined
Jul 29, 2001
Messages
21,334
Here's a quicky you can modify to suit your needs:

PHP:
	<SCRIPT LANGUAGE="Javascript">
			<!--
				var randNumber = Math.round(Math.random() * 4)
				if (randNumber == 0)
				{
				document.write('<A href="http://www.intel.com">Intel</A><br><A href="http://www.cisco.com">Cisco</A>');
				}
				if (randNumber == 1)
				{
				document.write('<A href="http://forums.techguy.org/">Tech Guy</A><br><a href="http://www.4guysfromrolla.com/">4 Guys from Rolla</a>');
				}
				if (randNumber == 2)
				{
				document.write('So What!');
				}
				if (randNumber == 3)
				{
				document.write('Sumthin...Sumthin');
				}
				if (randNumber == 4)
				{
				document.write('You first');
				}
			// -->
			</SCRIPT>
Copy and paste it into the body of any web page. If you want more random indexes just change the variable *4 so the script can tell what number of random numbers to select from.
 

ckaas

Thread Starter
Joined
Feb 3, 2003
Messages
133
thanks rockn, if i were to replace document.write by document.replace and specified another page, would that work also? :)
 
Joined
Jul 29, 2001
Messages
21,334
The replace function is meant to replace something in a string. Say there were commas in a text string that you wanted to replace with semi-colons document.replace('textstring, ",", ";")

Something like that.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top