onerror sự kiện kích hoạt khi xảy ra lỗi trong HTML. Bạn có thể thử chạy mã sau để triển khai onerror thuộc tính sự kiện -
Ví dụ
<!DOCTYPE html>
<html>
<body>
<img src = "new.png" onerror = "display()">
<p>Alert would be visible, if the image isn't loaded correctly.</p>
<script>
function display() {
alert("Image load unsuccessful.");
}
</script>
</body>
</html>