Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
'Uncaught TypeError' only on first page load only in Chrome on desktop. Works on second or more page loads. What is happening?

I have this problem that only exists on first page load in Chrome on desktop. It works in Chrome on the second or more page loads. It also works on mobile in Chrome on every page load.

It works fine in Safari and Firefox, MOST OF THE TIME. I have experienced the below error there as well, only on first page load, only on desktop, but I am not able to reproduce it there for about an entire day now.

Does anyone know what is going on?

The only thing I have been able to come up with is that somehow my redirect function is triggered. Because as you can see in the flow indicated below at number 6, after the error, the page redirects back to index.html. However that function would only trigger if the value of one of my sessionStorage values is null and I can see in the browser console that those values are set correctly when I press the button to go to the next page.

The error:

pic of error code

The flow:

  1. Landing page is index.html with separate index.js
  2. Upon selection of a few drop-downs, 3 values are stored in sessionStorage
  3. Next page is called: normal-quiz.html with separate normal-quiz.js
  4. Values from sessionStorage are retrieved to filter a data array
  5. The loadQuiz function runs on the filtered array and sets a question element value to an object's 'english' property
  6. On first page load, only in Chrome on desktop, the above error occurs which makes the browser return to index.html and sessionStorage is cleared
  7. If I try the above again, it works without a problem

The line generating the error is where I use the loadQuiz function to set the question element's value in my html to the 'english' property value of the first object in the filtered array.

The code (js):

function redirect() {
if (selectedBook !== null) {
    // do nothing
} else {
    window.location = "<myURL>"
};
};

redirect();

function loadQuiz() {
const currentQuizData = quizArr[currentQuiz]; // currentQuiz is the question counter. It starts at 0 to get the first object, then increments by 1 after each question

questionEl.innerText = currentQuizData.english;
// line above is where the error is generated

counter.innerText = (currentQuiz + 1) + "/" + quizArr.length;
};
loadQuiz();
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!