window.jsReportedErrorsCount = 0; window.onerror = function(errorMsg, file, lineNr) { /* These exceptions are a result of a server error and should be ignored by the JS error handler since they are already logged server-side. */ if (errorMsg.indexOf('Server Ajax Error')>=0) return true; //Set a repoting limit count to prevent error handler from going haywire. if(window.jsReportedErrorsCount > 100) return; var reportUrl = '/reportJsError.php'; //Our server-side JavaScript error collector var reportUrlArgs = "?errorMsg="+encodeURIComponent(errorMsg); //Set the error message reportUrlArgs += "&errorFile="+encodeURIComponent(file); //Set the file the error occured in reportUrlArgs += "&errorLineNr="+encodeURIComponent(lineNr); //Set the line nr the error occured at reportUrlArgs += "&" + encodeURIComponent(Math.random()); //Add a random number to prevent caching //Construct JS include URL var url = "https://airnet.org.au"+reportUrl+reportUrlArgs; //FIXME home URL should be set! /* This adds a JS include to the page. So far this appears to be the most reliable way to report errors to our server. */ $("head").append( $("