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.
|
||||
Load a random pageRocket 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. anarchy3200 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. Kurashu 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'; //etc. $link = array_rand($links); echo '<a href="' . $link . '">Random Link</a>'; Rocket Boy 10-30-2005, 12:48 AM Thanks, all good info! VortexCortex 11-05-2005, 02:03 AM <html><head><title>multi-link</title> <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/"; window.onload=function(){ if(typeof(document.getElementById)!="undefined"){ document.getElementById("rndLink").setAttribute("href",links[Math.floor(Math.random()*numLinks)]); } } //--></script> </head><body> <a href="http://www.google.com/" id="rndLink">Random Link</a> </body> </html> This example uses javascript, and degrades gracefully. |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum