browserSettings.newTabPosition
一个 BrowserSetting
对象,可用于控制新打开标签页相对于已打开标签页的位置。
其底层值是一个字符串,可以取三个值中的一个:
- “afterCurrent”:在当前标签页旁边打开所有新标签页。
- “relatedAfterCurrent”:默认值。如果新标签页与当前标签页相关联(例如,通过当前标签页中的链接打开),则在当前标签页旁边打开新标签页。否则,在标签栏的末尾打开新标签页。
- “atEnd”:在标签栏的末尾打开所有新标签页。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
newTabPosition |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
示例
以下代码将值设置为“afterCurrent”,然后记录新值:
js
async function setAfterCurrent() {
let result = await browser.browserSettings.newTabPosition.set({
value: "afterCurrent",
});
console.log(`结果:${result}`);
let newValue = await browser.browserSettings.newTabPosition.get({});
console.log(`新值:${newValue.value}`);
}