Search code examples
javascriptdom-events

JavaScript global event mechanism


I would like to catch every undefined function error thrown. Is there a global error handling facility in JavaScript? The use case is catching function calls from flash that are not defined.


Solution

  • Does this help you:

    <script>
    window.onerror = function() {
        alert("Error caught");
    };
    
    xxx();
    </script>
    

    I'm not sure how it handles Flash errors though...

    Update: it doesn't work in Opera, but I'm hacking Dragonfly right now to see what it gets. Suggestion about hacking Dragonfly came from this question:

    Mimic Window. onerror in Opera using javascript