I am trying to capture instances of missing resources by adding the following code snippet to my <head> site:
window.onerror = function(message, file, line) { console.log('Error:', message, file, line); }
But it only seems to capture JS errors, not common DOM errors. I tried consciously: 1) creating <script> tags that point to nonexistent files, and 2) creating <img> tags that point to nonexistent images. Does not fire an error event.
My questions:
- What errors occur while listening to
onerror ? - How can I capture these errors? Why is this code not working?
source share