/ Published in: JavaScript

1. no need to wrap the (potentially) offending code in try/catch
2. use window.onerror:
2. use window.onerror:
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script> (function(){ var old = window.onerror; window.onerror = function (msg, url, line) { if(typeof old==="function") { old(msg,url,line);} _gaq.push(['_trackEvent', 'Error Log', msg, url+'_'+line]); }; }()); </script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXXXXXX-Y']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>
URL: http://dl.dropbox.com/u/397675/error_test.html
Comments
