Use the history
API to interact with the browser history.
If you are looking for information about the browser session history, see the History interface.
Note: Downloads are treated as HistoryItem
objects. Therefore, events such as history.onVisited
fire for downloads.
Browser history is a chronological record of pages the user has visited. The history API enables you to:
However, the user may have visited a single page multiple times, so the API also has the concept of "visits". So you can also use this API to:
To use this API, an extension must request the "history" permission in its manifest.json
file.
history.TransitionType
history.HistoryItem
Provides information about a particular page in the browser history.
history.VisitItem
Describes a single visit to a page.
history.search()
history.HistoryItem
objects matching the given criteria.history.getVisits()
history.addUrl()
history.deleteUrl()
history.deleteRange()
history.deleteAll()
history.onTitleChanged
history.onVisited
history.HistoryItem
data for that page.history.onVisitRemoved
Fired when a URL is removed completely from the browser history.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
HistoryItem |
Yes |
79 |
49 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
TransitionType |
Yes |
79 |
50 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
VisitItem |
Yes |
79 |
50 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
addUrl |
Yes |
79 |
49 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
deleteAll |
Yes |
79 |
49 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
deleteRange |
Yes |
79 |
49 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
deleteUrl |
Yes |
79 |
49 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
getVisits |
Yes |
79 |
50 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
onTitleChanged |
No |
No |
55 |
? |
No |
No |
? |
? |
No |
? |
? |
? |
onVisitRemoved |
Yes |
79 |
50 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
onVisited |
Yes |
79 |
50
Before version 56, the result object's 'title' was always an empty string. From version 56 onwards, it is set to the last known title, if that is available, or an empty string otherwise.
|
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
search |
Yes |
79 |
49 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
Note: This API is based on Chromium's chrome.history
API. This documentation is derived from history.json
in the Chromium code.
Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/history