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