// Declare Error Handler
function oops()
{
alert ('Error!');
return true;
}// Assign to global error handler
window.onerror = oops;// Trigger an error
x.y.z();
This does not work, and it makes me sad.
Updated – removed syntax error from example
// Declare Error Handler
function oops()
{
alert ('Error!');
return true;
}// Assign to global error handler
window.onerror = oops;// Trigger an error
x.y.z();
This does not work, and it makes me sad.
Updated – removed syntax error from example
As far as I can tell, this is still the case, and still frustrating…
Any word on whether it might someday change?
I live in hope.
I pasted your example into the latest version of Safari and it appeared to work…
But alas, there’s a bug in your example – it should be
window.onerror = oops
and it’s still not working… 😦
Actually, window.onerror is not part of any specification
Four year later, and Safari still doesn’t have window.onerror, even though it is now part of the HTML spec.
As a kludgy work-around, I’ve put together genericOnError, which emulates window.onerror for Safari and Opera.
It won’t make you happy, just a little less sad.