Make your own free website on Tripod.com

Universal Random Number Function

This page illustrates a custom JavaScript function that returns a random number. Unlike Math.random, which fails in Netscape Navigator 2.0, this function works in all JavaScript-capable browsers. To see/swipe the function, see code and instructions in this page's document source.



Click the button above to view a random number between 1 and 100.

The syntax for calling the randnum function is:

randnum(lowest,highest) 

where lowest is the smallest acceptable random number, and highest is the highest acceptable number. For example this page calls the randnum() function with the syntax randnum(1,100) to get a random number between 1 and 100.