windows.getLastFocused()

Gets the window that was most recently focused — typically the window 'on top'.

Syntax

browser.windows.getLastFocused(
  getInfo,               // optional object
  function(window) {...} // function
)

Parameters

getInfoOptional
object.
populateOptional
boolean. If true, the windows.Window object will have a tabs property that contains a list of the tabs.Tab objects. The Tab objects only contain the url, title and favIconUrl properties if the extension's manifest file includes the "tabs" permission.
windowTypesOptional
array of windows.WindowType. If set, the windows.Window returned will be filtered based on its type. If unset the default filter is set to ['app', 'normal', 'panel', 'popup'], with 'app' and 'panel' window types limited to the extension's own windows.
callback
function. The function is passed the following arguments:
window
windows.Window.

Browser compatibility

EdgeFirefoxChromeOpera
Basic support?45.0Yes33
Firefox
Basic supportNo

Examples

Acknowledgements

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

Document Tags and Contributors

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