C
crazydave
Hi,
I've been using window.onerror to capture and report JavaScript errors
from other users for debugging an application I've written. But I've
run into a strange issue with Firefox and window.onerror.
It seems that any code that executes, having originated from an
"element.addEventListener", causing an error does not activate
"window.onerror". But it does at least show up in Firefox's JavaScript
error console. Internet Explorer doesn't appear to suffer from the
same issue when it uses it's equivalent "element.attachEvent".
Does anyone know why this is and if there is any workarounds or if it's
possibly a bug?
Code Example:
var ErrorHandler = function(msg, url, line) {
alert(msg+': '+url+': '+line);
};
window.onerror = ErrorHandler;
var Func = function(e) {
// The following line should cause an error since the variables don't
exist
noSuchVar = imagination.figment;
};
window.onload = function(e) {
// This activates window.onerror when "test1" is clicked
document.getElementById('test1').onclick = Func;
// In FF, this does not activate window.onerror when "test2" is
clicked
document.getElementById('test2').addEventListener('click', Func,
false);
};
I've been using window.onerror to capture and report JavaScript errors
from other users for debugging an application I've written. But I've
run into a strange issue with Firefox and window.onerror.
It seems that any code that executes, having originated from an
"element.addEventListener", causing an error does not activate
"window.onerror". But it does at least show up in Firefox's JavaScript
error console. Internet Explorer doesn't appear to suffer from the
same issue when it uses it's equivalent "element.attachEvent".
Does anyone know why this is and if there is any workarounds or if it's
possibly a bug?
Code Example:
var ErrorHandler = function(msg, url, line) {
alert(msg+': '+url+': '+line);
};
window.onerror = ErrorHandler;
var Func = function(e) {
// The following line should cause an error since the variables don't
exist
noSuchVar = imagination.figment;
};
window.onload = function(e) {
// This activates window.onerror when "test1" is clicked
document.getElementById('test1').onclick = Func;
// In FF, this does not activate window.onerror when "test2" is
clicked
document.getElementById('test2').addEventListener('click', Func,
false);
};