var ErrorLogger = Class.create(); ErrorLogger.prototype = { initialize: function(url, opts){ this.url = url; this.active = true; this.opts = opts; window.onerror = this.onError.bind(this); }, onError: function(msg, URI, line){ try{ if(this.active){ var body = 'URI=' + escape(URI) + '&line=' + line + '&msg=' + escape(msg) + '&brw=' + escape(Object.toJSON(Prototype.Browser)) + '&pv=' + escape(Prototype.Version); if('onError' in this.opts)this.opts.onError.apply(this, arguments); var opts = { onSuccess : this.onSuccess.bind(this), onFailure : this.onComplete, postBody : body }; new Ajax.Request(this.url, opts); } }catch(e){ this.onFailure(); } return true; }, onSuccess: function(){ if('onSuccess' in this.opts)this.opts.onSuccess.apply(this, arguments); }, onFailure: function(){ this.active = false; if('onFailure' in this.opts)this.opts.onFailure.apply(this, arguments); } };