執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
轉到Spaces
<!DOCTYPE html> <html> <body> <p>Use the addEventListener() method to attach a "error" event to an img element.</p> <img id="myImg" src="image.gif"> <p id="demo"></p> <script> document.getElementById("myImg").addEventListener("error", myFunction); function myFunction() { document.getElementById("demo").innerHTML = "The image could not be loaded."; } </script> </body> </html>