使用 HTML5 通知激活浏览器选项卡

Activate browser tab using HTML5 Notification

我正在使用 HTML5 Notification API to show a message if new content is available. I'd like to show the browser tab that caused the notification to be activated when the user clicks the message, but I haven't been able to find an API to do so. I did find the Page Visibility API,但它似乎只在选项卡更改时发送事件,不允许我激活选项卡。

是否可以这样控制浏览器,还是根本不允许?

如果有的话,window.focus() 应该从通知的 click 事件处理程序中进行。

详情见https://notifications.spec.whatwg.org/#activating-a-notification