September 27, 2000 - Randomizing a Link | WebReference

September 27, 2000 - Randomizing a Link

Yehuda Shiran September 27, 2000
Randomizing a Link
Tips: September 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

A good way to draw attention to your site is to surprise users with something new and different each time they visit your site. Displaying a random link is one way to achieve that effect. There are many techniques to pick a link or a message in random. Here is a simple script that will do the trick. It displays the following link (reload the tip to see a different link):

And here is the code:

var urlarray= new Array("",
var textarray= new Array("Brio Support Center",
      "IBM Aptiva Center",
      "Acer Technologies",
      "toshiba site");
urlstr="<a href=\""+urlarray[randomno]+"\">"
document.write (urlstr);

This tip has been contributed by Pratim Guha Biswas.

Learn more about random banners in Column 60, Persistent Random Banners.