Support Center

Catching errors in client-side Javascript

Last Updated: Apr 06, 2012 10:53AM EDT
In some cases it is helpful to automatically trap errors and have events posted to Loggr. Javascript has a global event (window.onerror) that gets fired when a runtime error occurs. Use the code below to handle that event and post an error to Loggr.

window.onerror = function (msg, url, line) {
    var data = "Message: " + msg + "<br>";
    data += "URL: " + url + "<br>";
    data += "Line: " + line + "<br>";
    data += "Platform: " + navigator.platform + "<br>";
    data += "User Agent: " + navigator.userAgent + "<br>";
        .text("Runtime error: " + msg)

See Documentation
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found