我们的志愿者还没有将这篇文章翻译为 中文 (简体)。加入我们帮助完成翻译!
您也可以阅读此文章的English (US)版。
This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
The PerformanceNavigationTiming interface provides methods and properties to store and retrieve metrics regarding the browser's document navigation events. For example, this interface can be used to determine how much time it takes to load or unload a document.
<div id="interfaceDiagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 11.666666666666666%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 70" preserveAspectRatio="xMinYMin meet"><a xlink:href="https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigationTiming" target="_top"><rect x="1" y="1" width="270" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text x="136" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">PerformanceNavigationTiming</text></a></svg></div>
a:hover text { fill: #0095DD; pointer-events: all;}
Properties
This interface extends the following PerformanceEntry properties for navigation performance entry types by qualifying and constraining them as follows:
PerformanceEntry.entryTypeRead only- Returns
"navigation". PerformanceEntry.nameRead only- Returns the document's address.
PerformanceEntry.startTimeRead only- Returns a
timestampwith a value of "0". PerformanceEntry.durationRead only- Returns a
timestampthat is the difference between thePerformanceNavigationTiming.loadEventEndandPerformanceEntry.startTimeproperties.
The interface also supports the following properties:
PerformanceNavigationTiming.domCompleteRead only- A
DOMHighResTimeStamprepresenting a time value equal to the time immediately before the browser sets the current document readiness of the current document to complete. PerformanceNavigationTiming.domContentLoadedEventEndRead only- A
DOMHighResTimeStamprepresenting the time value equal to the time immediately after the current document's DOMContentLoaded event completes. PerformanceNavigationTiming.domContentLoadedEventStartRead only- A
DOMHighResTimeStamprepresenting the time value equal to the time immediately before the user agent fires the DOMContentLoaded event at the current document. PerformanceNavigationTiming.domInteractiveRead only- A
DOMHighResTimeStamprepresenting atimestamprepresenting the time value equal to the time immediately before the user agent sets the current document readiness of the current document to interactive. PerformanceNavigationTiming.loadEventEndRead only- A
DOMHighResTimeStamprepresenting the time when the load event of the current document is completed. PerformanceNavigationTiming.loadEventStartRead only- A
DOMHighResTimeStamprepresenting the time value equal to the time immediately before the load event of the current document is fired. PerformanceNavigationTiming.redirectCountRead only- A number representing the number of redirects since the last non-redirect navigation under the current browsing context.
PerformanceNavigationTiming.typeRead only- A
stringrepresenting the navigation type. Must be: "navigate", "reload", "back_forward" or "prerender". PerformanceNavigationTiming.unloadEventEndRead only- A
DOMHighResTimeStamprepresenting the time value equal to the time immediately after the user agent finishes the unload event of the previous document. PerformanceNavigationTiming.unloadEventStartRead only- A
DOMHighResTimeStamprepresenting the time value equal to the time immediately before the user agent starts the unload event of the previous document.
Methods
PerformanceNavigationTiming.toJSON()- Returns a
DOMStringthat is the JSON representation of thePerformanceNavigationTimingobject.
Specifications
| Specification | Status | Comment |
|---|---|---|
| Navigation Timing Level 2 The definition of 'PerformanceNavigationTiming' in that specification. |
Editor's Draft | Initial definition. |
Browser compatibility
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|---|
| Basic support. | 57 | (Yes) | No support | No support | 44 | No support |
| Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|---|---|
| Basic support. | 57 | 57 | (Yes) | No support | No support | No support | 44 | No support |