blob: 6710b0e023f61993e5c2a34e6603f6ae89f573ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
---
title: 'HTMLMediaElement: abort event'
slug: Web/API/HTMLMediaElement/abort_event
translation_of: Web/API/HTMLMediaElement/abort_event
---
<div>{{APIRef}}</div>
<p>资源没有被完全加载时就会触发 <strong><code>abort</code></strong> 事件,但错误不会触发该事件。</p>
<table class="properties">
<tbody>
<tr>
<th scope="row">Bubbles</th>
<td>No</td>
</tr>
<tr>
<th scope="row">Cancelable</th>
<td>No</td>
</tr>
<tr>
<th scope="row">Interface</th>
<td>{{domxref("Event")}}</td>
</tr>
<tr>
<th scope="row">Event handler property</th>
<td>{{domxref("GlobalEventHandlers/onabort", "onabort")}}</td>
</tr>
</tbody>
</table>
<h2 id="示例">示例</h2>
<pre class="brush: js">const video = document.querySelector('video');
const videoSrc = 'https://path/to/video.webm';
video.addEventListener('abort', () => {
console.log(`Abort loading: ${videoSrc}`);
});
const source = document.createElement('source');
source.setAttribute('src', videoSrc);
source.setAttribute('type', 'video/webm');
video.appendChild(source);</pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('HTML WHATWG', "media.html#event-media-abort")}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', "embedded-content-0.html#event-media-abort")}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.HTMLMediaElement.abort_event")}}</p>
<h2 id="参阅">参阅</h2>
<ul>
<li>{{domxref("HTMLAudioElement")}}</li>
<li>{{domxref("HTMLVideoElement")}}</li>
<li>{{HTMLElement("audio")}}</li>
<li>{{HTMLElement("video")}}</li>
</ul>
<div id="gtx-trans" style="position: absolute; left: 7px; top: 1375px;">
<div class="gtx-trans-icon"></div>
</div>
|