For a project i am trying to create a special way to browse through a website by having a "go to random page" button, similar to the way wikipedia does it here wikipage random button on the left, see here https://en.wikipedia.org/wiki/Main_Page.
for this purpose I have to question. A - Is it possible to create a function that search all the existing index[].html on my website and puts them into an array ? B - Is it possible to dynamically update this array as I am adding new pages to my website (like wikipedia adds new articles) ?
basically something like this ! thank you !
find a way to go through the website and add all html to an array
var diary = ["index1.html", "index2.html", '...'];
access random page
function accessrandompage() {
var randompage = Math.floor(Math.random() * diary.length);
window.location.replace("index" + randompage + ".html");
}
Aucun commentaire:
Enregistrer un commentaire