View Full Version : Load a random page

Rocket Boy
10-29-2005, 12:27 PM
The title speaks for itself, I hope somebody can help. I just need to create a link. Instead of the link going to a specific page though it needs to load 1 of 20-30 pages at random.

10-29-2005, 04:25 PM
Try asking this in the javascript catergory as this cannot be done without any extra scripting to add the randomisation.

10-29-2005, 04:37 PM
If you use PHP here's a simple script that'll do it for you.

$links = array();
$links[] = 'http://www.example.com/page1.php';
$links[] = 'http://www.example.com/page2.php';
$links[] = 'http://www.example.com/page3.php';
$links[] = 'http://www.example.com/page4.php';
$link = array_rand($links);
echo '<a href="' . $link . '">Random Link</a>';

Rocket Boy
10-30-2005, 12:48 AM
Thanks, all good info!

11-05-2005, 02:03 AM
<script type="text/javascript"><!--
var numLinks = 4;
var links = new Array(numLinks);
links[0] = "http://www.lycos.com/";
links[1] = "http://www.yahoo.com/";
links[2] = "http://www.google.com/";
links[3] = "http://www.altavista.com/";
<a href="http://www.google.com/" id="rndLink">Random Link</a>

This example uses javascript, and degrades gracefully.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum