HTMLonerrorイベント属性

❮HTMLイベント属性

画像の読み込み中にエラーが発生した場合は、JavaScriptを実行します。

<img src="image.gif" onerror="myFunction()">

定義と使用法

onerror属性は、外部ファイル(ドキュメントや画像など)のロード中にエラーが発生した場合に発生します。


ブラウザのサポート

Event Attribute
onerror Yes Yes Yes Yes Yes

構文

<element onerror="script">

属性値

Value Description
script The script to be run on onerror

技術的な詳細

サポートされているHTMLタグ: <img>、<input type = "image">、<object>、<link>、および<script>

関連ページ

HTML DOMリファレンス:onerrorイベント


❮HTMLイベント属性