-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69a6abf
commit dfe42a4
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
files/zh-cn/mozilla/add-ons/webextensions/api/pageaction/isshown/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: pageAction.isShown() | ||
slug: Mozilla/Add-ons/WebExtensions/API/pageAction/isShown | ||
l10n: | ||
sourceCommit: 43e3ff826b7b755b05986c99ada75635c01c187c | ||
--- | ||
|
||
{{AddonSidebar}} | ||
|
||
如果在指定的标签页中页面操作正在显示中,则返回 `true`。 | ||
|
||
这是一个返回 [`Promise`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise) 的异步函数。 | ||
|
||
## 语法 | ||
|
||
```js-nolint | ||
let gettingIsShown = browser.pageAction.isShown( | ||
details // 对象 | ||
) | ||
``` | ||
|
||
### 参数 | ||
|
||
- `details` | ||
|
||
- : `object`。包含要检查的 `tabId` 的对象。 | ||
|
||
- `tabId` | ||
- : `integer`。要检查的标签页的 ID。 | ||
|
||
### 返回值 | ||
|
||
[`Promise`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise),如果在指定的标签页中拓展的页面操作正在显示。则兑现为 `true`,否则兑现为 `false`。 | ||
|
||
## 浏览器兼容性 | ||
|
||
{{Compat}} | ||
|
||
## 示例 | ||
|
||
Check the state of the currently active tab: | ||
|
||
```js | ||
async function shownInActiveTab() { | ||
let tabs = await browser.tabs.query({ | ||
currentWindow: true, | ||
active: true, | ||
}); | ||
let shown = await browser.pageAction.isShown({ | ||
tabId: tabs[0].id, | ||
}); | ||
console.log(shown); | ||
} | ||
``` | ||
|
||
{{WebExtExamples}} |