在未来一个特定的时间运行的计划任务代码。这很像setTimeout()
和setInterval()
,不过这些函数仅可以按需使用而不能在后台页面工作。
想要使用这个API,您需要获取"alarms"的permission。
类型
alarms.Alarm
- Information about a particular alarm.
方法
alarms.create()
- 创建新的alarm.
alarms.get()
- 通过名称获取指定的alarm.
alarms.getAll()
- 获取所有的alarm.
alarms.clear()
- 清除指定名称的alarm.
alarms.clearAll()
- 清除所有的alarm.
事件
alarms.onAlarm
- 当alarm发生的时候触发.
浏览器兼容性
BCD tables only load in the browser
The "Chrome incompatibilities" section is included from https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities using the WebExtChromeCompat macro.
If you need to update this content, edit https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities, then shift-refresh this page to see your changes.
Example extensions
Acknowledgements
This API is based on Chromium's chrome.alarms
API.
Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.