编辑下面的代码:【加编码】
<html> <body> <p>该实例演示了如何向 img 元素中添加 "onerror" 事件。</p> <img src="/demo/image.gif" onerror="myFunction()"> <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML = "无法加载图片。"; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂