0
擴展在收到消息時發送通知。使Chrome擴展程序刷新已打開頁面而不是打開新頁面
var notification = new Notification('New message', {
icon: icon,
body: dabody,
});
它還打開一個頁面,顯示單擊時的消息。
notification.onclick = function() {
window.open(link);
chrome.tabs.create({url: "https://website/messages/", selected: false, pinned: true}, function(tab) {
chrome.tabs.executeScript(tab.id, {
code: 'window.close();',
runAt: 'document_idle'
});
});
notification.close();
}
有沒有一種方法可以讓我有/messages
刷新頁面,如果它已經打開,而不是打開一個新的網頁嗎?
見['tabs.update()'](https://developer.chrome.com/extensions/tabs#method-update)。 – Makyen