get window errors js code example
Example: js catch all images errors
document.addEventListener('error', (e) => {
console.log('Document error triggered!')
if (!e.target) {
return console.log('Received event without target!')
}
const errorTarget = e.target
const imageErrorSource = errorTarget instanceof HTMLImageElement
if (!imageErrorSource) return false
return true
}, true)