tabs.create()
새 탭을 만든다.
이것은 비동기 함수로 Promise
를 돌려준다.
문법
var creating = browser.tabs.create(
createProperties // object
)
매개변수
createProperties
-
object
. 새 탭에 대한 속성들. 속성들에 대해 더 배우려면tabs.Tab
(en-US) 문서를 보라.active
Optional-
boolean
. 활성탭이 되는지를 정한다. 윈도우의 포커스에는 영향이 없다(windows.update
(en-US) 참조). 기본값은true
. -
string
. 탭의 쿠키 저장 ID를cookieStoreId
로 지정한다. 이 옵션은 확장이"cookies"
권한을 가져야 쓸 수 있다. index
Optional-
integer
. 윈도우에서 탭의 위치를 지정한다. 쓸 수 있는 값은 0에서 윈도에 있는 탭의 수까지다. openerTabId
Optional-
integer
. The ID of the tab that opened this tab. If specified, the opener tab must be in the same window as the newly created tab. openInReaderMode
Optional-
boolean
. Iftrue
, open this tab in Reader Mode. Defaults tofalse
. pinned
Optional-
boolean
. Whether the tab should be pinned. Defaults tofalse
. selected
Optional-
boolean
. 윈도우에서 탭이 선택되는지를 지정한다. 기본값은true
.경고: 이 속성은 사용이 중단되었다. 파이어폭스에서는 지원하지 않는다.
active
가 대신한다. url
Optional-
string
. 최초 표시될 URL. 기본값은 새 탭 페이지다. URL은 반드시 scheme를 포함해야 한다 (가령은 'http://www.google.com'은 되지만, 'www.google.com'은 안된다). 보안상 파이어폭스에서 특권이 있는 URL은 안된다. 그래서 아래와 같은 URL을 주면 실패할 것이다:- chrome: URL
- javascript: URL
- data: URL
- file: URL (예, 파일시스템의 파일들. 단, 확장 안에 포함된 파일의 사용은 아래를 보라)
- 특권이 있는 about: URL (예,
about:config
,about:addons
,about:debugging
). 특권이 없는 URL은 된다 (예,about:blank
). - 새 탭 페이지 (
about:newtab
)는 URL 값이 주어지지 않으면 열린다.
확장에 포함된 페이지의 로딩은 확장의 manifest.json 파일이 있는데서 시작하는 절대 경로를 써라. 예를 들면: '/path/to/my-page.html'. 만약 첫 '/'를 빼면 URL은 상대 경로로 취급되고, 다른 브라우저들은 다른 절대 경로를 생성해낼 것이다.
windowId
Optional-
integer
. 새 탭이 만들어질 윈도우. 기본값은 현재 윈도우.
Return value
A Promise
that will be fulfilled with a tabs.Tab
(en-US) object containing details about the created tab. If the tab could not be created (for example, because url
used a privileged scheme) the promise will be rejected with an error message.
브라우저 호환성
BCD tables only load in the browser
예제
Open "https://example.org" in a new tab:
function onCreated(tab) {
console.log(`Created new tab: ${tab.id}`)
}
function onError(error) {
console.log(`Error: ${error}`);
}
browser.browserAction.onClicked.addListener(function() {
var creating = browser.tabs.create({
url:"https://example.org"
});
creating.then(onCreated, onError);
});
Example extensions
- commands
- contextual-identities
- find-across-tabs
- firefox-code-search
- open-my-page-button
- permissions
- store-collected-images
- tabs-tabs-tabs
참고: AcknowledgementsThis API is based on Chromium's chrome.tabs
API. This documentation is derived from tabs.json
in the Chromium code.Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.