ACtl.openURL
This function is the API counterpart of the open URL action.
It opens one or more URLs in existing tabs or new tabs.
ACtl.openURL(urls,tabSpec)
ACtl.openURL(urls[,options]) urls Type: string | Array
A single URL or an array of URLs to open.
tabSpec Type: TabSpec
One or more tabs in which to open the URLs specified by the urls argument. It can be either a tab ID, a filter object, a tab-selection name or an array combining all that. Full details at Tab Specifier.
If not enough tabs are given to open all URLs, new tabs will be created.
options Type: Object Default: {}
An object with only one of the following properties:
newWindow Type: string
One or more of the following strings separated by a space character:
normal | The URLs will open in one new window with several tabs (one per URL).
|
popup | The URLs will open each in a new popup window.
|
incognito | The new windows created (normal or popup) will be incognito windows.
You must enable the Allow in incognito option in the extension's settings.
|
rightOf Type: TabSpec Default: '#rightmostTab'
A tab to use as a reference point. The URLs given by urls will be opened in new tabs positioned to the right of this reference tab.
It can be either a tab ID, a filter object, a tab-selection name or an array combining all that. Full details at Tab Specifier.
If more than one tab is given, only the first one will be used.
leftOf Type: TabSpec
Same as rightOf, but the new tabs will be on the left of the reference tab.
Returns Type: Promise Resolves to: Array
Returns immediately. The Promise will resolve with an array of tab IDs.
These are the tabs in which the URLs were opened.
Throws Type: string
Error description if urls contains a malformed URL or
if tabSpec, leftOf or rightOf are not valid Tab Specifiers.
Examples
Open a URL in a new tab at the rightmost position in the current window.
let [newTabId] = await ACtl.openURL('http://example.com') ;
Open a URL in the active tab of the current window.
ACtl.openURL('http://example.com', '#currentTab') ;
Open two URLs in new tabs at the left of the current tab.
let urls = ['http://example.com/page1', 'http://example.com/page2'] ;
let newTabIds = await ACtl.openURL(urls, {leftOf: '#currentTab'}) ;
Open a URL in a new incognito window.
let [tabId] = await ACtl.openURL('http://example.com', {newWindow: 'incognito'});