小编use*_*122的帖子

在时间用完后重新打开Chrome时,Chrome扩展程序警报会消失吗?

使用Google Chrome扩展程序警报时,如果已设置并且Chrome已关闭并在警报到期后重新打开,则警报将会关闭.

我怎么能阻止这个?

这是一个小代码示例来解释我的意思.

/* 
If we perform Browser Action to create alarm, then 
close the browser, wait about 2 minutes for the alarm to expire
and then reopen the browser, the alarm will go off and the DoSomething 
function will get called twice, once by the onStartup event and once
by the onAlarm event.
*/
chrome.browserAction.onClicked.addListener(function (tab) {
    chrome.alarms.create('myAlarm', {
        delayInMinutes : 2.0
    });
});

chrome.alarms.onAlarm.addListener(function (alarm) {
    console.log('Fired alarm!');
    if (alarm.name == 'myAlarm') {
        createListener();
    }
});

chrome.runtime.onStartup.addListener(function …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome javascript-events alarm google-chrome-extension

4
推荐指数
1
解决办法
5224
查看次数