September 27, 2000 - Randomizing a Link
![]() |
September 27, 2000 Randomizing a Link Tips: September 2000
Yehuda Shiran, Ph.D.
|
And here is the code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
var urlarray= new Array("http://www.hp.com/brio",
"http://www.ibm.com",
"http://www.acer.com",
"http://www.toshiba.com");
var textarray= new Array("Brio Support Center",
"IBM Aptiva Center",
"Acer Technologies",
"toshiba site");
randomno=Math.floor((Math.random()*urlarray.length));
urlstr="<a href=\""+urlarray[randomno]+"\">"
urlstr+=textarray[randomno];
urlstr+="</a>"
document.write (urlstr);
</SCRIPT>
</BODY>
</HTML>This tip has been contributed by Pratim Guha Biswas.
Learn more about random banners in Column 60, Persistent Random Banners.


Find a programming school near you