tabs.sendRequest()

Sends a single request to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The extension.onRequest event is fired in each content script running in the specified tab for the current extension.

Syntax

browser.tabs.sendRequest(
  tabId,                   // integer
  request,                 // any
  function(response) {...} // optional function
)

Parameters

tabId
integer.
request
any.
responseCallbackOptional
function. The function is passed the following arguments:
response
any. The JSON response object sent by the handler of the request. If an error occurs while connecting to the specified tab, the callback will be called with no arguments and runtime.lastError will be set to the error message.

Browser compatibility

EdgeFirefoxChromeOpera
Basic support?NoYesNo
Firefox
Basic supportNo

Examples

Acknowledgements

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

Document Tags and Contributors

 Contributors to this page: wbamberg, rolfedh
 Last updated by: wbamberg,