Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • That actually doesn't make any difference for Safari -- it still doesn't fire the error handler.
    – David
    Commented Feb 11, 2009 at 21:35
  • I had a problem with an onclick handler in safari and this was what fixed it, so I thought it'd be the same for onerror too. Apparently not...
    – user42092
    Commented Feb 11, 2009 at 21:53
  • 1
    Should this work for statically included script tags too, or just ones injected dynamically? I just tried to use it to detect if jQuery failed to load but it didn't work. I'm not sure if I'm doing it wrong or it just doesn't work in this case. Commented Dec 26, 2011 at 21:50
  • 1
    @hippietrail - an event listener will never work on a static HTML <script>. If you try to add it before then you get an error that the tag doesn't exist, and if you add it after then the script's already run and triggered its events. The only way there is to look for side effects caused by the script.
    – user42092
    Commented Jan 1, 2012 at 3:12
  • Thanks flussence. Too bad that this only works for 404, not for JS errors. Setting a variable inside the script is not always practicable.
    – Jo Liss
    Commented Mar 23, 2012 at 17:06