|
|
Subject:
JS - onload redirect to one of a random list of pages
Category: Computers > Internet Asked by: cclegg06-ga List Price: $5.00 |
Posted:
23 Oct 2003 07:58 PDT
Expires: 22 Nov 2003 06:58 PST Question ID: 269024 |
I need a JavaScript that onload will automatically redirect to one of a list of pages, randomly. For example, 1. Visitor visits page 2. instantly, the page reloads to a new page (Page A, Page B, or Page C - choosen at random) |
|
Subject:
Re: JS - onload redirect to one of a random list of pages
Answered By: tar_heel_v-ga on 23 Oct 2003 09:50 PDT Rated: |
cclegg06... Thanks for your question. Below is a javascript that will accomplish what you want: <!-- ONE STEP TO INSTALL RANDOM PAGE: 1. Copy the coding into the HEAD of your HTML document --> <!-- STEP ONE: Paste this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin var howMany = 2; // max number of items listed below var page = new Array(howMany+1); page[0]="first-random-page.html"; page[1]="second-random-page.html"; page[2]="third-random-page.html"; function rndnumber(){ var randscript = -1; while (randscript < 0 || randscript > howMany || isNaN(randscript)){ randscript = parseInt(Math.random()*(howMany+1)); } return randscript; } quo = rndnumber(); quox = page[quo]; window.location=(quox); // End --> </SCRIPT> </HEAD> <p><center> <font face="arial, helvetica" size="-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center><p> <!-- Script Size: 0.89 KB --> Thanks again for your question. If you need additional clarification, please let me know. Regards, -THV Search Strategy: javascript redirect random page Reference: The JavaScript Source: Navigation: Random Page: http://javascript.internet.com/navigation/random-page.html |
cclegg06-ga
rated this answer:
Thank you |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |