---
title: HTMLMediaElement.onerror
slug: Web/API/HTMLMediaElement/onerror
tags:
  - API
  - Audio
  - Errors
  - Event Handler
  - HTML DOM
  - HTMLMediaElement
  - Media
  - Property
  - Reference
  - Video
  - onerror
translation_of: Web/API/HTMLMediaElement/onerror
---
<div>{{APIRef("HTML DOM")}}</div>

<p>{{domxref("HTMLMediaElement")}} インターフェースの <strong><code>onerror</code></strong> プロパティは、{{event("error")}} イベントを処理するための {{event("Event_handlers", "event handler")}} です。</p>

<p><code>error</code> イベントは、メディアを読み込んだり実行しようとしたときに何らかのエラーが発生したときに発生します。</p>

<h2 id="Syntax" name="Syntax">構文</h2>

<pre class="syntaxbox"><em>HTMLMediaElement</em>.onerror = <em>EventListener</em>;</pre>

<h3 id="Value" name="Value">値</h3>

<p>{{event("error")}} イベントのイベントハンドラとして機能する {{jsxref("function")}}。 エラーが発生すると、指定した関数が呼び出されます。 <code>null</code> の場合、エラーハンドラは無効です。</p>

<h2 id="Specifications" name="Specifications">仕様</h2>

<table class="spectable standard-table">
 <tbody>
  <tr>
   <th scope="col">仕様</th>
   <th scope="col">状態</th>
   <th scope="col">コメント</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG','webappapis.html#handler-onerror','onerror')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>



<p>{{Compat("api.HTMLMediaElement.onerror")}}</p>

<h2 id="See_also" name="See_also">関連情報</h2>

<ul>
 <li>{{domxref("HTMLMediaElement")}}</li>
 <li>{{HTMLElement("audio")}} と {{HTMLElement("video")}}</li>
</ul>