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

218
Views
"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
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!