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

220
Visualizações
"Script error" reported in window.onerror without cross-site scripting

Almost every JS error I get using window.onerror is the unhelpful "Script error" message.

I have read everything I can find on this but it is always said it is caused by cross-site scripting, but there's none in my code.

Why do these unhelpful error messages appear and how can I replace them with the full messages that appear in the console?

As a test example, I created a minimal HTML/JS code pair. This is the HTML page, testpage.html:

<html>
<head></head>
  <body>
    <script src="/js/testpage.min.js"></script>
  </body>
</html>

and JS script:

window.onerror = function(msg, url, lineNo, columnNo, error) {
  // code goes here to generate log entry on the server
  return true;
}
// generate illustrative sample error
var jsonData = "";
var data = JSON.parse(jsonData);

Running this, msg = "Script error" and other parameters are either null or zero. The Google DevTools console displays the full error:

Uncaught SyntaxError: Unexpected end of JSON input
  at JSON.parse (<anonymous>)
  at testpage.min.js:7

Any help towards being able to log the full error messages will be most welcome. I'm at a complete loss.

EDIT: Recast to make problem clearer.

about 4 years ago · Juan Pablo Isaza
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