aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/timeranges/length
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/timeranges/length
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/timeranges/length')
-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>