Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/history/index.md
6580 views
---
title: history slug: Mozilla/Add-ons/WebExtensions/API/history page-type: webextension-api tags: - API - Add-ons - Extensions - History - Interface - Non-standard - Reference - WebExtensions browser-compat: webextensions.api.history
---

{{AddonSidebar}}

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.

Types

  • {{WebExtAPIRef("history.TransitionType")}}

    • : Describes how the browser navigated to a particular page.

  • {{WebExtAPIRef("history.HistoryItem")}}

    • : Provides information about a particular page in the browser history.

  • {{WebExtAPIRef("history.VisitItem")}}

    • : Describes a single visit to a page.

Functions

  • {{WebExtAPIRef("history.search()")}}

  • {{WebExtAPIRef("history.getVisits()")}}

    • : Retrieves information about visits to a given page.

  • {{WebExtAPIRef("history.addUrl()")}}

    • : Adds a record to the browser history of a visit to the given page.

  • {{WebExtAPIRef("history.deleteUrl()")}}

    • : Removes all visits to the given URL from the browser history.

  • {{WebExtAPIRef("history.deleteRange()")}}

    • : Removes all visits to pages that the user made during the given time range.

  • {{WebExtAPIRef("history.deleteAll()")}}

    • : Removes all visits from the browser history.

Events

  • {{WebExtAPIRef("history.onTitleChanged")}}

    • : Fired when the title of a page visited by the user is recorded.

  • {{WebExtAPIRef("history.onVisited")}}

    • : Fired each time the user visits a page, providing the {{WebExtAPIRef("history.HistoryItem")}} data for that page.

  • {{WebExtAPIRef("history.onVisitRemoved")}}

    • : Fired when a URL is removed completely from the browser history.

Browser compatibility

{{Compat}}

{{WebExtExamples("h2")}}

Note: This API is based on Chromium's chrome.history API. This documentation is derived from history.json in the Chromium code.