--- title: HTMLMediaElement.loop slug: Web/API/HTMLMediaElement/loop translation_of: Web/API/HTMLMediaElement/loop ---
{{APIRef("HTML DOM")}}
 
HTMLMediaElement.loop 属性是 HTML 标签 {{htmlattrxref("loop", "video")}} 属性的映射,它决定了媒体元素播放结束时是否重新开始。
 

原文:The HTMLMediaElement.loop property reflects the {{htmlattrxref("loop", "video")}} HTML attribute, which controls whether the media element should start over when it reaches the end.

语法

var loop = video.loop;
audio.loop = true;

返回值

一个布尔值 {{domxref("Boolean")}}.

示例

var obj = document.createElement('video');
obj.loop = true; // true

规范

Specification Status Comment
{{SpecName('HTML WHATWG', "the-video-element.html#htmlmediaelement", "HTMLMediaElement.loop")}} {{Spec2('HTML WHATWG')}} No change from {{SpecName('HTML5 W3C')}}
{{SpecName('HTML5 W3C', "embedded-content-0.html#htmlmediaelement", "HTMLMediaElement.loop")}} {{Spec2('HTML5 W3C')}} Initial definition.

浏览器兼容性

{{ CompatibilityTable() }}

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
loop property {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatGeckoDesktop("11.0")}} {{CompatIE("9")}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Edge Firefox Mobile (Gecko) Firefox OS (Gecko) IE Mobile Opera Mobile Safari Mobile
loop property {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatGeckoMobile("11.0")}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

相关链接