[JavaScript] 网页中通过onerror事件控制图片加载失败后执行指定的JS代码 →→→→→进入此内容的聊天室

来自 , 2019-12-23, 写在 JavaScript, 查看 108 次.
URL http://www.code666.cn/view/4afe0449
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script>
  5. function imgError()
  6. {
  7. alert('The image could not be loaded.');
  8. }
  9. </script>
  10. </head>
  11. <body>
  12.  
  13. <img src="image.gif" onerror="imgError()">
  14. <p>A function is triggered if an error occurs when loading the image. The function shows an alert box with a text.
  15. In this example we refer to an image that does not exist, therefore the onerror event occurs.</p>
  16.  
  17. </body>
  18. </html>
  19.  
  20. //javascript/7959

回复 "网页中通过onerror事件控制图片加载失败后执行指定的JS代码"

这儿你可以回复上面这条便签

captcha