View Full Version : random url redirect

01-23-2009, 04:12 PM
I'm new to java script and looking for a way to (automatically) and randomly redirect a user to one of a list of urls after going to the redirect page.


user is sent to /redirect.htm

instantly then sent to either page1 page 2 or page 3 randomly (or if possible based off a percentage)

so page1 (30% of the time); page 2 (50%); page 3 (20%)

any help would be greatly appreciated

01-23-2009, 04:44 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var pages = ['page1.htm', 'page2.htm', 'page3.htm'];
n = n < 3? 0 : n < 8? 1 : 2;
})(Math.floor(Math.random() * 10));