Edit The Code:
See Result »
Try it Yourself - ©
w3big.com
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>本教程(w3big.com)</title> </head> <body> <img src="image.gif" onerror="myFunction()"> <p>如果在加载图片时发生错误则触发函数 myFunction() 函数会弹出提示窗口。</p> 该实例中我们引用的图片不存在,因此会触发 onerror 事件。 <script> function myFunction() { alert('无法加载图片。'); } </script> </body> </html>