0
Thanks

A few words of thanks would be greatly appreciated.

Javascript - Choosing a Random Link



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 = "http://ccm.net/"; 
    Url[0] = "index.php3"; 
    Url[1] = "wifi"; 
    Url[2] = "php"; 
    Url[3] = "forum/"; 

    Linkchoice = Math.round(Math.random() * (Url.length+1)); 
    window.open(base + Url[Linkchoice],'_blank'); 
} 
//--> 
</SCRIPT>



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>


0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jean-François Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled « Javascript - Choosing a Random Link », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!