chrome.history
For information on how to use experimental APIs, see the chrome.experimental.* APIs page.
Use the chrome.history
module to interact with the
browser's record of visited pages. You can add, remove, and query
for URLs in the browser's history.
To override the history page with your own version, see
Override Pages.
Manifest
You must declare the "history" permission
in the extension manifest
to use the history API.
For example:
{
"name": "My extension",
...
"permissions": [
"history"
],
...
}
Transition types
The history API uses a transition type to describe
how the browser navigated to a particular URL
on a particular visit.
For example, if a user visits a page
by clicking a link on another page,
the transition type is "link".
The following table describes each transition type.
Transition type | Description |
"link" |
The user got to this page by clicking a link on another page.
|
"typed" |
The user got this page by typing the URL in the address bar.
Also used for other explicit navigation actions.
See also generated,
which is used for cases where the user selected a choice
that didn't look at all like a URL.
|
"auto_bookmark" |
The user got to this page through a suggestion in the UI —
for example, through a menu item.
|
"auto_subframe" |
Subframe navigation.
This is any content that is automatically
loaded in a non-top-level frame.
For example, if a page consists of
several frames containing ads,
those ad URLs have this transition type.
The user may not even realize the content in these pages
is a separate frame, and so may not care about the URL
(see also manual_subframe).
|
"manual_subframe" |
For subframe navigations that are explicitly requested by the user
and generate new navigation entries in the back/forward list.
An explicitly requested frame is probably more important than
an automatically loaded frame
because the user probably cares about the fact that
the requested frame was loaded.
|
"generated" |
The user got to this page by typing in the address bar
and selecting an entry that did not look like a URL.
For example, a match might have the URL of a Google search result page,
but it might appear to the user as "Search Google for ...".
These are not quite the same as typed navigations
because the user didn't type or see the destination URL.
See also keyword.
|
"start_page" |
The page was specified in the command line or is the start page.
|
"form_submit" |
The user filled out values in a form and submitted it.
Note that in some situations —
such as when a form uses script to submit contents —
submitting a form does not result in this transition type.
|
"reload" |
The user reloaded the page,
either by clicking the reload button
or by pressing Enter in the address bar.
Session restore and Reopen closed tab use this transition type, too.
|
"keyword" |
The URL was generated from a replaceable keyword
other than the default search provider.
See also
keyword_generated.
|
"keyword_generated" |
Corresponds to a visit generated for a keyword.
See also keyword.
|
Examples
For examples of using this API, see the
history sample directory and the
history API test directory.
For other examples and for help in viewing the source code, see
Samples.
API reference: chrome.history
Properties
getLastError
chrome.extensionlastError
Methods
addUrl
void
chrome.history.addUrl(, object
details)
Undocumented.
Adds a URL to the history at the current time with a transition type of "link".
Parameters
-
details
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
url
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- The URL to add.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Type param1, Type param2) {...};
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
deleteAll
void
chrome.history.deleteAll(, function
callback)
Undocumented.
Deletes all items from the history.
Parameters
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...};
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
deleteRange
void
chrome.history.deleteRange(, object
range, function
callback)
Undocumented.
Removes all items within the specified date range from the history. Pages will not be removed from the history unless all visits fall within the range.
Parameters
-
range
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
startTime
(
optional
enumerated
Type
array of
number
)
-
Undocumented.
- Items added to history after this date, represented in milliseconds since the epoch.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
endTime
(
optional
enumerated
Type
array of
number
)
-
Undocumented.
- Items added to history before this date, represented in milliseconds since the epoch.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...};
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
deleteUrl
void
chrome.history.deleteUrl(, object
details)
Undocumented.
Removes all occurrences of the given URL from the history.
Parameters
-
details
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
url
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- The URL to remove.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Type param1, Type param2) {...};
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
getVisits
void
chrome.history.getVisits(, object
details, function
callback)
Undocumented.
Retrieve information about visits to a URL.
Parameters
-
details
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
url
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- The URL for which to retrieve visit information. It must be in the format as returned from a call to history.search.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(array of VisitItem results) {...};
-
results
(
optional
enumerated
Type
array of
VisitItem
array of
paramType
paramType
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
search
void
chrome.history.search(, object
query, function
callback)
Undocumented.
Search the history for the last visit time of each page matching the query.
Parameters
-
query
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
text
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- A free-text query to the history service. Leave empty to retrieve all pages.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
startTime
(
optional
enumerated
Type
array of
number
)
-
Undocumented.
- Limit results to those visited after this date, represented in milliseconds since the epoch.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
endTime
(
optional
enumerated
Type
array of
number
)
-
Undocumented.
- Limit results to those visited before this date, represented in milliseconds since the epoch.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
maxResults
(
optional
enumerated
Type
array of
integer
)
-
Undocumented.
- The maximum number of results to retrieve. Defaults to 100.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(array of HistoryItem results) {...};
-
results
(
optional
enumerated
Type
array of
HistoryItem
array of
paramType
paramType
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Events
onVisitRemoved
chrome.history.onVisitRemoved.addListener(function(object removed) {...});
Undocumented.
Fired when one or more URLs are removed from the history service. When all visits have been removed the URL is purged from history.
Parameters
-
removed
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
allHistory
(
optional
enumerated
Type
array of
boolean
)
-
Undocumented.
- True if all history was removed. If true, then urls will be empty.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
urls
(
optional
enumerated
Type
array of
Type
array of
string
paramType
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
onVisited
chrome.history.onVisited.addListener(function(HistoryItem result) {...});
Undocumented.
Fired when a URL is visited, providing the HistoryItem data for that URL.
Parameters
-
result
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Types
HistoryItem
paramName
(
optional
enumerated
Type
array of
object
)
Undocumented.
An object encapsulating one result of a history query.
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
id
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- The unique identifier for the item.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
url
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- The URL navigated to by a user.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
title
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- The title of the history page.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
lastVisitTime
(
optional
enumerated
Type
array of
number
)
-
Undocumented.
- When this page was last loaded, represented in milliseconds since the epoch.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
visitCount
(
optional
enumerated
Type
array of
integer
)
-
Undocumented.
- The number of times the user has navigated to this page.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
typedCount
(
optional
enumerated
Type
array of
integer
)
-
Undocumented.
- The number of times the user has navigated to this page by typing in the address.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
VisitItem
paramName
(
optional
enumerated
Type
array of
object
)
Undocumented.
An object encapsulating one visit to a URL.
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
id
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- The unique identifier for the item.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
visitId
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- The unique identifier for this visit.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
visitTime
(
optional
enumerated
Type
array of
number
)
-
Undocumented.
- When this visit occurred, represented in milliseconds since the epoch.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
referringVisitId
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- The visit_id of the referrer.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
transition
(
optional
enumerated
Type
array of
string
["link", "typed", "auto_bookmark", "auto_subframe", "manual_subframe", "generated", "start_page", "form_submit", "reload", "keyword", "keyword_generated"]
)
-
Undocumented.
- The transition type for this visit from its referrer.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-