Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- random choice from array of functions


Fotiman - 11:20 pm on Mar 21, 2011 (gmt 0)


I suspect the problem lies elsewhere, and not with the bit of code relating to the random function call. Here's a quick test case:

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<a href="#" onclick="doPage();")>readout test</a>.
<script>
function page1() {
alert('page1');
}
function page2() {
alert('page2');
}
function page3() {
alert('page3');
}
function doPage() {
var pages = [page1, page2, page3],
randomnumber = Math.floor(Math.random() * pages.length);
pages[randomnumber]();
}
</script>
</body>
</html>


That should at least demonstrate that this part is functioning.


Thread source:: http://www.webmasterworld.com/javascript/4284932.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com