Random message generation

Random message generation
06 February 2004

Like to get a few marketing messages in front of visitors while they browse? Here’s a script that can do just that.

What this script does is create a text box on a web page and display one of any number of pre-defined messages each time the page is loaded.

The following part of the three stage script needs to be inserted between the <head> and </head> tags of your webpage. This script has some generic messages already in place, but these can be replaced with your own. Be careful not to delete any of the quote marks or commas or the script won’t work


<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
quotes = new Array("10 per cent off all stock this month",
 "Free home delivery with orders over £50",
 "See special offers for news of our latest deals",
 "Thanks for your visit")
brave = quotes.length
function randQuote(){
 randomNum = Math.floor
  ((Math.random() * brave))
 document.mesays.quoterot.value = quotes[randomNum]
}
</SCRIPT>


Next, the line of code below replaces the <body> tag on your webpage.

<BODY onLoad="randQuote()">

Finally, the third part of the script below determines where the random message appears. The settings can be changed to suit your site and message.

<div align="center">
<FORM name="random message">
<INPUT type="text" name="quoterot" size="55" style="font:bold 10px verdana;color:#FFFFFF;background-color:#FF0000;">
</FORM>
</div>