--- title: Document.timeline slug: Web/API/Document/timeline tags: - API - Animation - Document - Property - 属性 - 文档 translation_of: Web/API/Document/timeline --- <div>{{ SeeCompatTable() }}{{ APIRef("Web Animations") }}</div> <p>{{domxref("Document")}} 接口的 <code>timeline</code> 只读属性表示当前文档的默认时间轴。 此时间轴是 {{domxref("DocumentTimeline")}} 的一个特殊实例,它会在网页加载时自动创建。</p> <p>此时间轴对于每个文档(<code>document</code>)来说都是唯一的,并在文档的生命周期中保持不变,包括调用 {{domxref("Document.open()")}}。</p> <p>该时间线的时间值被计算为与全局时钟的固定偏移,使得零时间对应于{{domxref("PerformanceTiming.navigationStart", "navigationStart")}}时刻加上称为原始时间的带符号的delta 。 在建立导航开始时刻之前,文档时间线是不活动的。</p> <div class="note"> <p><strong>注意:</strong>与非活动文档相关联的文档时间轴也被视为是<strong>不活动的</strong>。</p> </div> <h2 id="语法">语法</h2> <div class="syntaxbox"> <pre class="brush: js">var pageTimeline = document.timeline; var thisMoment = pageTimeline.currentTime;</pre> </div> <h3 id="值">值</h3> <p>一个 {{domxref("DocumentTimeline")}} 对象。</p> <h2 id="规则">规则</h2> <table class="standard-table"> <tbody> <tr> <th scope="col">规范</th> <th scope="col">状态</th> <th scope="col">备注</th> </tr> <tr> <td>{{SpecName('Web Animations', '#dom-document-timeline', 'document.timeline' )}}</td> <td>{{Spec2('Web Animations')}}</td> <td>Editor's draft.</td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("api.Document.timeline")}}</p> <h2 id="参见">参见</h2> <ul> <li><a href="/zh-CN/docs/Web/API/Web_Animations_API">Web Animations API</a></li> <li>{{domxref("AnimationTimeline")}}</li> <li>{{domxref("AnimationTimeline.currentTime")}}</li> <li>{{domxref("DocumentTimeline")}}</li> </ul>