Video autoplay 属性
实例
例子 1
查看视频是否在准备好后立即开始播放:
var x = document.getElementById("myVideo").autoplay;
例子 2
启用自动播放,并重新加载视频:
var x = document.getElementById("myVideo"); x.autoplay = true; x.load();
例子 3
演示如何创建 <video> 元素并设置 autoplay 属性:
var x = document.createElement("VIDEO");
语法
返回 autoplay 属性:
videoObject.autoplay
设置 autoplay 属性:
videoObject.autoplay = true|false
属性值
值 | 描述 |
---|---|
true|false |
规定视频是否应在加载后立即自动开始播放。
|
Technische Details
Rückgabewert: | Boolscher Wert, wird auf true zurückgegeben, wenn das Video automatisch abgespielt wird, sonst auf false. |
---|---|
Standardwert: | false |
Browserunterstützung
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Unterstützung | 9.0 | Unterstützung | Unterstützung | Unterstützung |
Verwandte Seiten
HTML-Referenzhandbuch:HTML <video> autoplay-Attribut