Description:
This JavaScript flips through a list of Sites that you provide and when a user clicks a button, they are transported to the site that is listed in the text box.
JavaScript Functions: <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function makeArray(q){ for(i=1 ; i < q ; i++){this[i]=0}} w=1; howmanysites=4; // How many sites are listed below? Sites = new makeArray(howmanysites); <!-- STEP TWO: Use the pattern: url~Site Title|Description for links --> Sites[1] = "http://www.cgi-resources.com~CGI Resource Index|CGI scripts!"; Sites[2] = "http://www.geocities.com~Geocities|Free webspace!"; Sites[3] = "http://www.yahoo.com~Yahoo!|Great Directory!"; Sites[4] = "http://www.webknowhow.net~WebKnowHow.Net|Webmaster resources!"; function showSites() { if (w > howmanysites) { w=1; }; var string=Sites[w] + ""; var split1=string.indexOf("~"); var split2=string.indexOf("|"); var url=string.substring(0,split1); var name=string.substring(split1 + 1,split2); var word=string.substring(split2 + 1,string.length); document.form.url.value=url; document.form.name.value=name; document.form.word.value=word; w+=1; window.setTimeout('showSites()',3000); // You can change the speed! 3000 = 3 sec delay. 5000 = 5 sec delay, etc. } function visitSite() { window.location=document.form.url.value; } // End --> </SCRIPT>
HTML Script: <table width=420> <tr> <td align=center> <center> <form name=form> <table><tr><td align=center> <input type=button name=name value="Visit" onClick="visitSite()" size=25> <input type=hidden name=url value=""> <input type=text name=word value="" size=40> </td></tr></table> </form> </center> <script> showSites(); </script> </td> </tr> </table>