I am trying to create a button that will randomly take you to a website from a list I created. It works except for one problem: Every now and then it will go to an error page as it tries to go to a "undefined" page. Could you take a look at my code and see if you can find where my flaw is?
<html>
<head>
<base href="http://www.angelfire.com/realm/angelicknight/projects/ezring.html">
<script language="JavaScript">
var members = new Array(3);
members[0] = "http://www.abacusconnection.com";
members[1] = "http://www.activeyears.com";
members[2] = "http://www.axciom.com";
function randomgo()
{
var a = Math.round(Math.random()*3)
var i = a
location.href = members[a]
}
</script>
</head>
<body>
<form>
<input type="button" name="random" value="Random" onclick="randomgo();">
</form>
</body>
</html>
<html>
<head>
<base href="http://www.angelfire.com/realm/angelicknight/projects/ezring.html">
<script language="JavaScript">
var members = new Array(3);
members[0] = "http://www.abacusconnection.com";
members[1] = "http://www.activeyears.com";
members[2] = "http://www.axciom.com";
function randomgo()
{
var a = Math.round(Math.random()*3)
var i = a
location.href = members[a]
}
</script>
</head>
<body>
<form>
<input type="button" name="random" value="Random" onclick="randomgo();">
</form>
</body>
</html>
Comment