1. Mozilla
  2. Add-ons
  3. Browser extensions
  4. JavaScript APIs
  5. tabs
  6. tabs.goBack()

tabs.goBack()

Navigate to the previous page in tab's history, if available.

This is an asynchronous function that returns a Promise.

Syntax

js
let withGoingBack = browser.tabs.goBack(
 tabId, // optional integer
 callback // optional function
)

Parameters

tabId Optional

integer. The ID of the tab to navigate. Defaults to the active tab of the current window.

callback Optional

function. When the page navigation finishes, this function is called without parameters.

Return value

A Promise that is fulfilled when the page navigation finishes.

Examples

Go back to the previous page in the current tab:

js
function onGoBack() {
 console.log("Gone back");
}
function onError(error) {
 console.log(`Error: ${error}`);
}
let goingBack = browser.tabs.goBack();
goingBack.then(onGoBack, onError);

Browser compatibility

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

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.

AltStyle によって変換されたページ (->オリジナル) /