The GetNavigationTime method measures how long the most
recent navigation has taken, reported in milliseconds. If a navigation is
currently in progress, the elapsed time represents the duration since the
navigation began. If the navigation has already completed, the elapsed time
represents the total duration of that navigation. If no navigation has
occurred, the elapsed time will be zero.
This method can be used for diagnostics, performance monitoring, or
implementing application-level timeouts. For example, an application may
track whether a page is taking unusually long to load and decide to cancel
the navigation, notify the user, or retry the request. Combined with
GetNavigationStatus, it provides a way to determine both the
state and timing of navigation operations.
Typical usage scenarios for this method include:
- Measuring page load times for performance profiling or telemetry.
- Implementing a custom navigation timeout by checking the elapsed time in a periodic timer.
- Providing user feedback, such as displaying how long a page has been loading.
- Logging navigation duration along with success or failure status for diagnostic purposes.
The lpbNavigating parameter indicates whether a navigation is
currently in progress when the method is called. This allows developers
to distinguish between a completed navigation (where the elapsed time is
final) and an in-progress navigation (where the elapsed time is still
increasing).
It is important to note that the reported time is based on the browser's
internal navigation start and completion timestamps. It reflects the overall
duration of the navigation process as observed by the browser, not fine-grained
network-level timings such as DNS lookup, TCP connection, or TLS handshake.
For most application scenarios this high-level timing is sufficient to
evaluate page load performance and detect unusual delays.