We would like to trap window.onerror so that we can do something
intelligent with Javascript errors. Unfortunately it appears as though
Prototype is doing something to defeat it?
I've put together a little example which demonstrates this. If I load
the following into Firefox and click on the text, I get an alert:
<html>
<head>
<title>Error test</title>
<script>
window.onerror=function(){alert("error happened")}
</script>
<script type="text/javascript" src="prototype.js"/>
</head>
<body>
<div onclick="nonexistent()">Click here for an error</div>
</body>
</html>
If, on the other hand, I try it with the following (the only
difference is the fact that prototype.js is loaded before the
window.onerror handler is installed), I don't:
<html>
<head>
<title>Error test</title>
<script type="text/javascript" src="prototype.js"/>
<script>
window.onerror=function(){alert("error happened")}
</script>
</head>
<body>
<div onclick="nonexistent()">Click here for an error</div>
</body>
</html>
This is with Firefox 2.0.0.14 and Prototype 1.6.0.2 running on Leopard
- I've not tested on other environments. I have Firebug installed, but
get the same behavior whether it's enabled or not.
I've crawled through the Prototype source to see if it's handling
window.onerror itself, but as far as I can see it's not touching it?
Am I missing something?
Thanks in advance for any help you can offer,
Paul.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---