Stay organized with collections Save and categorize content based on your preferences.
DescriptionUse the chrome.webNavigation
API to receive notifications about the status of navigation requests in-flight.
webNavigation
All chrome.webNavigation
methods and events require you to declare the "webNavigation"
permission in the extension manifest. For example:
{
"name": "My extension",
...
"permissions": [
"webNavigation"
],
...
}
Concepts and usage Event order
For a navigation that is successfully completed, events are fired in the following order:
onBeforeNavigate -> onCommitted -> [onDOMContentLoaded] -> onCompleted
Any error that occurs during the process results in an onErrorOccurred
event. For a specific navigation, there are no further events fired after onErrorOccurred
.
If a navigating frame contains subframes, its onCommitted
is fired before any of its children's onBeforeNavigate
; while onCompleted
is fired after all of its children's onCompleted
.
If the reference fragment of a frame is changed, a onReferenceFragmentUpdated
event is fired. This event can fire any time after onDOMContentLoaded
, even after onCompleted
.
If the history API is used to modify the state of a frame (e.g. using history.pushState()
, a onHistoryStateUpdated
event is fired. This event can fire any time after onDOMContentLoaded
.
If a navigation restored a page from the Back Forward Cache, the onDOMContentLoaded
event won't fire. The event is not fired because the content has already completed load when the page was first visited.
If a navigation was triggered using Chrome Instant or Instant Pages, a completely loaded page is swapped into the current tab. In that case, an onTabReplaced
event is fired.
There is no defined ordering between events of the webRequest API and the events of the webNavigation API. It is possible that webRequest events are still received for frames that already started a new navigation, or that a navigation only proceeds after the network resources are already fully loaded.
In general, the webNavigation events are closely related to the navigation state that is displayed in the UI, while the webRequest events correspond to the state of the network stack which is generally opaque to the user.
Tab IDsNot all navigating tabs correspond to actual tabs in Chrome's UI, for example, a tab that is being pre-rendered. Such tabs are not accessible using the tabs API nor can you request information about them by calling webNavigation.getFrame()
or webNavigation.getAllFrames()
. Once such a tab is swapped in, an onTabReplaced
event is fired and they become accessible through these APIs.
It's important to note that some technical oddities in the OS's handling of distinct Chrome processes can cause the clock to be skewed between the browser itself and extension processes. That means that the timeStamp
property of the WebNavigation
event timeStamp
property is only guaranteed to be internally consistent. Comparing one event to another event will give you the correct offset between them, but comparing them to the current time inside the extension (using (new Date()).getTime()
, for instance) might give unexpected results.
Frames within a tab can be identified by a frame ID. The frame ID of the main frame is always 0, the ID of child frames is a positive number. Once a document is constructed in a frame, its frame ID remains constant during the lifetime of the document. As of Chrome 49, this ID is also constant for the lifetime of the frame (across multiple navigations).
Due to the multi-process nature of Chrome, a tab might use different processes to render the source and destination of a web page. Therefore, if a navigation takes place in a new process, you might receive events both from the new and the old page until the new navigation is committed (i.e. the onCommitted
event is sent for the new main frame). In other words, it is possible to have more than one pending sequence of webNavigation events with the same frameId
. The sequences can be distinguished by the processId
key.
Also note that during a provisional load the process might be switched several times. This happens when the load is redirected to a different site. In this case, you will receive repeated onBeforeNavigate
and onErrorOccurred
events, until you receive the final onCommitted
event.
Another concept that is problematic with extensions is the lifecycle of the frame. A frame hosts a document (which is associated with a committed URL). The document can change (say by navigating) but the frameId won't, and so it is difficult to associate that something happened in a specific document with just frameIds. We are introducing a concept of a documentId which is a unique identifier per document. If a frame is navigated and opens a new document the identifier will change. This field is useful for determining when pages change their lifecycle state (between prerender/active/cached) because it remains the same.
Transition types and qualifiersThe webNavigation
onCommitted
event has a transitionType
and a transitionQualifiers
property. The transition type is the same as used in the history API describing how the browser navigated to this particular URL. In addition, several transition qualifiers can be returned that further define the navigation.
The following transition qualifiers exist:
Transition qualifier Description "client_redirect" One or more redirects caused by JavaScript or meta refresh tags on the page happened during the navigation. "server_redirect" One or more redirects caused by HTTP headers sent from the server happened during the navigation. "forward_back" The user used the Forward or Back button to initiate the navigation. "from_address_bar" The user initiated the navigation from the address bar (aka Omnibox). ExamplesTo try this API, install the webNavigation API example from the chrome-extension-samples repository.
Types Enum"client_redirect"
"server_redirect"
"forward_back"
"from_address_bar"
Cause of the navigation. The same transition types as defined in the history API are used. These are the same transition types as defined in the history API except with "start_page"
in place of "auto_toplevel"
(for backwards compatibility).
"link"
"typed"
"auto_bookmark"
"auto_subframe"
"manual_subframe"
"generated"
"start_page"
"form_submit"
"reload"
"keyword"
"keyword_generated"
chrome.webNavigation.getAllFrames(
details: object,
): Promise<object[] | undefined>
Retrieves information about all frames of a given tab.
ParametersInformation about the tab to retrieve all frames from.
Promise<object[] | undefined>
chrome.webNavigation.getFrame(
details: object,
): Promise<object | undefined>
Retrieves information about the given frame. A frame refers to an <iframe> or a <frame> of a web page and is identified by a tab ID and a frame ID.
ParametersInformation about the frame to retrieve information about.
documentId
string optional
The UUID of the document. If the frameId and/or tabId are provided they will be validated to match the document found by provided document ID.
The ID of the frame in the given tab.
processId
number optional
Deprecated since Chrome 49
Frames are now uniquely identified by their tab ID and frame ID; the process ID is no longer needed and therefore ignored.
The ID of the process that runs the renderer for this tab.
The ID of the tab in which the frame is.
Promise<object | undefined>
chrome.webNavigation.onBeforeNavigate.addListener(
callback: function,
filters?: object,
)
Fired when a navigation is about to occur.
ParametersThe callback
parameter looks like:
(details: object) => void
The lifecycle the document is in.
0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique for a given tab and process.
The type of frame the navigation occurred in.
parentDocumentId
string optional
A UUID of the parent document owning this frame. This is not set if there is no parent.
The ID of the parent frame, or -1
if this is the main frame.
Deprecated since Chrome 50
The processId is no longer set for this event, since the process which will render the resulting document is not known until onCommit.
The value of -1.
The ID of the tab in which the navigation is about to occur.
The time when the browser was about to start the navigation, in milliseconds since the epoch.
Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event.
chrome.webNavigation.onCommitted.addListener(
callback: function,
filters?: object,
)
Fired when a navigation is committed. The document (and the resources it refers to, such as images and subframes) might still be downloading, but at least part of the document has been received from the server and the browser has decided to switch to the new document.
ParametersThe callback
parameter looks like:
(details: object) => void
A UUID of the document loaded.
The lifecycle the document is in.
0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab.
The type of frame the navigation occurred in.
parentDocumentId
string optional
A UUID of the parent document owning this frame. This is not set if there is no parent.
The ID of the parent frame, or -1
if this is the main frame.
The ID of the process that runs the renderer for this frame.
The ID of the tab in which the navigation occurs.
The time when the navigation was committed, in milliseconds since the epoch.
A list of transition qualifiers.
Cause of the navigation.
Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event.
chrome.webNavigation.onCompleted.addListener(
callback: function,
filters?: object,
)
Fired when a document, including the resources it refers to, is completely loaded and initialized.
ParametersThe callback
parameter looks like:
(details: object) => void
A UUID of the document loaded.
The lifecycle the document is in.
0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab.
The type of frame the navigation occurred in.
parentDocumentId
string optional
A UUID of the parent document owning this frame. This is not set if there is no parent.
The ID of the parent frame, or -1
if this is the main frame.
The ID of the process that runs the renderer for this frame.
The ID of the tab in which the navigation occurs.
The time when the document finished loading, in milliseconds since the epoch.
Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event.
chrome.webNavigation.onCreatedNavigationTarget.addListener(
callback: function,
filters?: object,
)
Fired when a new window, or a new tab in an existing window, is created to host a navigation.
ParametersThe callback
parameter looks like:
(details: object) => void
The ID of the frame with sourceTabId in which the navigation is triggered. 0 indicates the main frame.
The ID of the process that runs the renderer for the source frame.
The ID of the tab in which the navigation is triggered.
The ID of the tab in which the url is opened
The time when the browser was about to create a new view, in milliseconds since the epoch.
The URL to be opened in the new window.
Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event.
chrome.webNavigation.onDOMContentLoaded.addListener(
callback: function,
filters?: object,
)
Fired when the page's DOM is fully constructed, but the referenced resources may not finish loading.
ParametersThe callback
parameter looks like:
(details: object) => void
A UUID of the document loaded.
The lifecycle the document is in.
0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab.
The type of frame the navigation occurred in.
parentDocumentId
string optional
A UUID of the parent document owning this frame. This is not set if there is no parent.
The ID of the parent frame, or -1
if this is the main frame.
The ID of the process that runs the renderer for this frame.
The ID of the tab in which the navigation occurs.
The time when the page's DOM was fully constructed, in milliseconds since the epoch.
Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event.
chrome.webNavigation.onErrorOccurred.addListener(
callback: function,
filters?: object,
)
Fired when an error occurs and the navigation is aborted. This can happen if either a network error occurred, or the user aborted the navigation.
ParametersThe callback
parameter looks like:
(details: object) => void
A UUID of the document loaded.
The lifecycle the document is in.
The error description.
0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab.
The type of frame the navigation occurred in.
parentDocumentId
string optional
A UUID of the parent document owning this frame. This is not set if there is no parent.
The ID of the parent frame, or -1
if this is the main frame.
Deprecated since Chrome 50
The processId is no longer set for this event.
The value of -1.
The ID of the tab in which the navigation occurs.
The time when the error occurred, in milliseconds since the epoch.
Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event.
chrome.webNavigation.onHistoryStateUpdated.addListener(
callback: function,
filters?: object,
)
Fired when the frame's history was updated to a new URL. All future events for that frame will use the updated URL.
ParametersThe callback
parameter looks like:
(details: object) => void
A UUID of the document loaded.
The lifecycle the document is in.
0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab.
The type of frame the navigation occurred in.
parentDocumentId
string optional
A UUID of the parent document owning this frame. This is not set if there is no parent.
The ID of the parent frame, or -1
if this is the main frame.
The ID of the process that runs the renderer for this frame.
The ID of the tab in which the navigation occurs.
The time when the navigation was committed, in milliseconds since the epoch.
A list of transition qualifiers.
Cause of the navigation.
Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event.
chrome.webNavigation.onReferenceFragmentUpdated.addListener(
callback: function,
filters?: object,
)
Fired when the reference fragment of a frame was updated. All future events for that frame will use the updated URL.
ParametersThe callback
parameter looks like:
(details: object) => void
A UUID of the document loaded.
The lifecycle the document is in.
0 indicates the navigation happens in the tab content window; a positive value indicates navigation in a subframe. Frame IDs are unique within a tab.
The type of frame the navigation occurred in.
parentDocumentId
string optional
A UUID of the parent document owning this frame. This is not set if there is no parent.
The ID of the parent frame, or -1
if this is the main frame.
The ID of the process that runs the renderer for this frame.
The ID of the tab in which the navigation occurs.
The time when the navigation was committed, in milliseconds since the epoch.
A list of transition qualifiers.
Cause of the navigation.
Conditions that the URL being navigated to must satisfy. The 'schemes' and 'ports' fields of UrlFilter are ignored for this event.
chrome.webNavigation.onTabReplaced.addListener(
callback: function,
)
Fired when the contents of the tab is replaced by a different (usually previously pre-rendered) tab.
ParametersThe callback
parameter looks like:
(details: object) => void
The ID of the tab that was replaced.
The ID of the tab that replaced the old tab.
The time when the replacement happened, in milliseconds since the epoch.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-11 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-11 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4