Answers for "js catch all images errors"

0

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)
Posted by: Guest on November-19-2020
0

js detect all images errors

window.addEventListener("error", e => {
  /* query selector images */
  // image element on error => replace source 
})
Posted by: Guest on November-19-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language