编辑下面的代码:【加编码】
<html> <body> <img src="/demo/image.gif" onerror="myFunction()"> <p>如果在加载图片时发生错误则触发函数 myFunction() 函数会弹出提示窗口。</p> 该实例中我们引用的图片不存在,因此会触发 onerror 事件。 <script> function myFunction() { alert('无法加载图片。'); } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂