aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/timeranges/length/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/timeranges/length/index.html')
-rw-r--r--files/zh-cn/web/api/timeranges/length/index.html59
1 files changed, 59 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/timeranges/length/index.html b/files/zh-cn/web/api/timeranges/length/index.html
new file mode 100644
index 0000000000..1fac25738a
--- /dev/null
+++ b/files/zh-cn/web/api/timeranges/length/index.html
@@ -0,0 +1,59 @@
+---
+title: TimeRanges.length
+slug: Web/API/TimeRanges/length
+translation_of: Web/API/TimeRanges/length
+---
+<div>{{APIRef("DOM")}}</div>
+
+<p>只读属性 <strong><code>TimeRanges.length</code></strong> 返回对象中时间范围的个数。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><em>length</em> = <em>TimeRanges</em>.length;
+</pre>
+
+<h2 id="示例">示例</h2>
+
+<p>假定页面中存在一个ID为“myVideo”的 video 元素:</p>
+
+<pre class="brush: js">var v = document.GetElementById("myVideo");
+
+var buf = v.buffered;
+
+var numRanges = buf.length;
+
+if (buf.length == 1) {
+ // Only one range
+ if (buf.start(0) == 0 &amp;&amp; buf.end(0) == v.duration) {
+ // The one range starts at the beginning and ends at
+ // the end of the video, so the whole thing is loaded
+ }
+}
+</pre>
+
+<p>这个例子演示了如何通过 <code>TimeRanges</code> 来判断 video 是否已经完全加载。</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName("HTML WHATWG", "#dom-timeranges-length", "TimeRanges.length()")}}</td>
+ <td>{{Spec2("HTML WHATWG")}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.TimeRanges.length")}}</p>