Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

207
Visualizações
'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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda