0

I want to dynamically route to one of 3 form types and I got it working on a separate branch but after merging it into master, it doesn't do it anymore. The URL gets set to the correct URL but it doesn't load the correct HTML/page.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link href="style/landingPage.scss" rel="stylesheet" />
    <link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
    <script type="module" src="js/landingPage.js"></script>
    <title>Recommender System</title>
  </head>
  <body>
    <div class="container py-4 px-3 mx-auto">
      <h1 class="text-center">Welcome!</h1>
      <p class="text-center">Thank you for participating in our study about recommender systems.</p>
      <a id="start-btn" class="btn btn-primary center">Find a friend!</a>
    </div>
  </body>
</html>
const init = () => {
  const aBtn = document.getElementById('start-btn');
  aBtn.onclick = () => {
    const formType = Math.floor(Math.random() * 3) + 1;
    const startTime = new Date().toString().split(' ')[4];
    window.localStorage.setItem('startTime', startTime);
    window.location.href = `/formType${formType}.html`;
  };
};

window.onload = () => init();

npm command: "start": "parcel --open",

Mout Pessemier
  • 1,665
  • 3
  • 19
  • 33

0 Answers0