4

I'm using the 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, but it only seems to send events when tabs change, not allow me to activate a tab.

Is it possible to control the browser like this, or is it simply not allowed?

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Jorn
  • 20,612
  • 18
  • 79
  • 126

1 Answers1

8

If anything, window.focus() should do it from inside the notification's click event handler.

See https://notifications.spec.whatwg.org/#activating-a-notification for details.

Anne
  • 7,070
  • 1
  • 26
  • 27