Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code samples are licensed under the BSD License.
©2011 Google
Use the chrome.webNavigation
module to receive
notifications about the status of navigations requests in-flight.
All chrome.webNavigation
methods and events require you to declare
the "webNavigation" permission in the extension
manifest.
For example:
{ "name": "My extension", ... "permissions": [ "webNavigation" ], ... }
You can find simple examples of using the tabs module in the examples/api/webNavigation directory. For other examples and for help in viewing the source code, see Samples.
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
.
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.
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 WebNavigation's events'
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 (via (new Date()).getTime()
, for instance) might give
unexpected results.
Retrieves information about all frames of a given tab.
The callback parameter should specify a function that looks like this:
function(array of object details) {...};
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.
The callback parameter should specify a function that looks like this:
function(object details) {...};
Fired when a navigation is about to occur.
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.
Fired when a document, including the resources it refers to, is completely loaded and initialized.
Fired when a new window, or a new tab in an existing window, is created to host a navigation.
Fired when the page's DOM is fully constructed, but the referenced resources may not finish loading.
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.
Fired when the reference fragment of a frame was updated. All future events for that frame will use the updated URL.