blob: 2a40195914fe1832c6774e1297c3e0ea823a7527 (
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
|
---
title: GlobalEventHandlers.onplay
slug: Web/API/GlobalEventHandlers/onplay
translation_of: Web/API/GlobalEventHandlers/onplay
---
<div>{{ ApiRef("HTML DOM") }}</div>
<p>The <code><strong>onplay</strong></code><em> </em>property of the {{domxref("GlobalEventHandlers")}} mixin is the {{event("Event_handlers")}} for processing {{event("play")}} events.</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox"><em><var>element</var></em>.onplay = <em>handlerFunction</em>;
var <em>handlerFunction</em> = <em><var>element</var></em>.onplay;
</pre>
<p><code>handlerFunction</code> 应该是 <code>null</code> 或者 <a href="/en-US/docs/Web/JavaScript/Reference/Functions" title="/en-US/docs/JavaScript/Reference/Functions_and_function_scope">JavaScript function</a> 指定事件的处理程序。</p>
<h2 id="示例">示例</h2>
<pre class="brush: html"><p>此示例演示如何将“onplay”事件分配给视频元素</p>
<video controls onplay="alertPlay()">
<source src="mov_bbb.mp4" type="video/mp4">
<source src="mov_bbb.ogg" type="video/ogg">
Your browser does not support HTML5 video.
</video>
<p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>
<script>
function alertPlay() {
alert("视频开始播放啦。");
}
</script>
</pre>
<h2 id="规范">规范</h2>
<table class="spectable standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('HTML WHATWG','webappapis.html#handler-onplay','onplay')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td>
<p> </p>
</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.GlobalEventHandlers.onplay")}}</p>
<h2 id="相关知识">相关知识</h2>
<ul>
<li>{{event("play")}}</li>
<li><a href="/en-US/docs/Web/Guide/Events/Event_handlers">Information on working with event handlers</a></li>
</ul>
|