Last active
December 11, 2015 02:08
-
-
Save Saturate/4528496 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onerror = function(msg, url, line) { | |
var loggerUrl = "/log/js"; | |
var parameters = "?description=" + escapemsg | |
+ "&url=" + escape(url) | |
+ "&line=" + escape(line) | |
+ "&parent_url=" + escape(document.location.href) | |
+ "&user_agent=" + escape(navigator.userAgent); | |
/* Send error to the server by loading this as a image url. It will work as a GET request */ | |
new Image().src = loggerUrl + parameters; | |
}; | |
// Not using image | |
window.onerror = function(msg, url, line) | |
{ | |
if(encodeURIComponent) { | |
var req = new AjaxRequest(); | |
var params = "msg=" + encodeURIComponent(msg) + '&url=' + encodeURIComponent(url) + "&line=" + line; | |
req.setMethod("POST"); | |
return req.loadXMLDoc("/log/js/", params); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment