Cut & Paste Random Link Generator by JavaScript Team | JavaScriptSource

Cut & Paste Random Link Generator by JavaScript Team

JavaScript Team Mar 25, 2012

Abstract

Random Link Script, randomly chooses between a custom list of url's

Description

This JavaScript will generate a random url by clicking on it. The script that will randomly choose between a specified pool of urls that you customize. The user will be redirected to that url after pressing the button.

Code Snippet

<script> <!-- /* Random link button- By JavaScript Kit (http://javascriptkit.com) Over 300+ free scripts! This credit MUST stay intact for use */  //specify random links below. You can have as many as you want var randomlinks=new Array()  randomlinks[0]="http://freewarejava.com" randomlinks[1]="http://javascriptkit.com" randomlinks[2]="http://dynamicdrive.com" randomlinks[3]="http://cnn.com" randomlinks[4]="http://www.geocities.com"  function randomlink(){ window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)] } //--> </script> <form> <p><input type="button" name="B1" value="Random Link >>" onclick="randomlink()"></p> </form>  <!--Uncomment below to use a regular text link instead <a href="javascript:randomlink()">Random Link</a> -->

Leave a Response

(2 comments)

Is nice!

Borat Jun 6, 2013

Thank you for your code.it is really useful for me.

baozulin Mar 27, 2012