Javascript - Choosing a Random Link

December 2016

The script below creates a hyperlink directing the visitor to an address chosen at random from a list.

The code below is to be inserted between the tag and <HEAD> </ HEAD> to top:

<SCRIPT Language="Javascript"> 
function RandomLink() 
    Url = new Array; 
    base = ""; 
    Url[0] = "index.php3"; 
    Url[1] = "wifi"; 
    Url[2] = "php"; 
    Url[3] = "forum/"; 

    Linkchoice = Math.round(Math.random() * (Url.length+1)); + Url[Linkchoice],'_blank'); 

The code below is to be inserted in the body of the page (somewhere between the tags and <BODY> </ BODY>) to display the link:

<A Href="#" onClick="RandomLink(); return(false)">RandomLink</A>

Related :

This document entitled « Javascript - Choosing a Random Link  » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.