I want a random homepage (from a predefined list) to show up when I click a link. And really this is Two questions so question one, is it possible? If yes then how?
What if the file are in different folders?
Would the code then look like this?
var arrPages = [ 'http://neo.graceland.edu/~rmthomas/gothyc%20cafe/feyra/feyra.html', 'http://neo.graceland.edu/~rmthomas/gothyc%20cafe/rayne/rayne.html', 'http://neo.graceland.edu/~rmthomas/gothyc%20cafe/adrienna/adrienna.html', 'http://neo.graceland.edu/~rmthomas/gothyc%20cafe/averya/aveyra.html', 'http://neo.graceland.edu/~rmthomas/gothyc%20cafe/demaen/demaen.html', 'http://neo.graceland.edu/~rmthomas/gothyc%20cafe/phoenyx/phoenyx.html', 'http://neo.graceland.edu/~rmthomas/gothyc%20cafe/raven/raven.html', 'http://neo.graceland.edu/~rmthomas/gothyc%20cafe/trysten/trysten.html', 'http://neo.graceland.edu/~rmthomas/gothyc%20cafe/xiandre/xiandre.html'];
document.getElementById('13').onclick = function () {
var randUrl = arrPages[Math.floor(Math.random() * arrPages.length)];
// Redirect/popup/new tab
window.open(randUrl,'test');
}
For an explanation of the functions used to set
randomIntsee Explain Math.floor(Math.random())