AutoControl Control your browser your way Forum               Install now from theChrome Web Store

ACtl.closeTab


Closes one or more tabs and windows. ACtl.closeTab([tabSpec]) tabSpec Type: TabSpec Default: undefined One or more tabs to close. 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 omitted, the tab the script is running in will be closed.
Returns Type: Promise Resolves to: number Returns immediately. The Promise will resolve with the number of tabs that were closed, which may be zero if tabSpec gives an empty set. Throws Type: string Error description if tabSpec is not a valid Tab Specifier.

Examples

Close all tabs to the right of the current tab.

	let tabCount = await ACtl.closeTab('#allRightTabs') ;
	

Close the current window.

	let tabCount = await ACtl.closeTab('#currWinTabs') ;
	

Open a URL in a pop-up window, then wait 2 seconds and close the window.

	let [tabId] = await ACtl.openURL('http://example.com', {newWindow: 'popup'}) ;
	await ACtl.sleep(2000) ;
	ACtl.closeTab(tabId) ;
	
Scripting API Script Isolation Asynchronicity Backgrnd Scripts GUI vs API ACtl.include ACtl.import ACtl.getFile ACtl.saveFile ACtl.saveURL ACtl.openURL ACtl.closeTab ACtl.runInTab ACtl.runInFrames ACtl.runInPageCtx ACtl.getTabInfo ACtl.getTabIds ACtl.TAB_ID ACtl.setTabState ACtl.captureTab ACtl.execAction ACtl.runCommand ACtl.getClipboard ACtl.setClipboard ACtl.expand ACtl.switchState ACtl.var ACtl.pubVar ACtl.on ACtl.off ACtl.sleep ACtl.STOP_CHAIN ACtl.STOP_FULL_SEQ