let user visit all html pages randomly assigned, making sure no page is repeated jquery/javascript -
i working on web-based experiment has on 90 pages (divided categories etc 6 groups)now, subjects/users have go through pages randomly assigned starting points..thanks stackoverflow have following..
<script type="text/javascript"> var pages = [ "page1.html", "page2.html", "page3.html" "page4.html" "page5.html" "page6.html" ]; function randompage() { return pages[math.round(math.random() * (pages.length - 1))]; } location.href= randompage(); </script>
this randomization , opens random page everytime however, want
1.make sure page(s) not repeated
2.each user visits pages
thanks in advance
on starting page
const maxpages = 6; const startingpage = math.floor(math.random() * maxpages) + 1;//random number between 1 , maxpages sessionstorage.setitem("startingpage", startingpage); window.location("page"+ startingpage + ".html");
on pagexx.html
var startingpage = parseint(sessionstorage.getitem("startingpage")); //check if startingpage number next page.
Comments
Post a Comment