tabs.connect()

Connects to the content script(s) in the specified tab. The runtime.onConnect event is fired in each content script running in the specified tab for the current extension. For more details, see content script messaging.

Syntax

browser.tabs.connect(
  tabId,      // integer
  connectInfo // optional object
)

Parameters

tabId
integer.
connectInfoOptional
object.
nameOptional
string. Will be passed into onConnect for content scripts that are listening for the connection event.
frameIdOptional
integer. Open a port to a specific frame identified by frameId instead of all frames in the tab.

Return value

runtime.Port. A port that can be used to communicate with the content scripts running in the specified tab. The port's runtime.Port event is fired if the tab closes or does not exist.

Browser compatibility

EdgeFirefoxChromeOpera
Basic support?45.0Yes33
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, PushpitaPikuDey, kmaglione
 Last updated by: wbamberg,