Clients.openWindow()

This is an experimental technologyBecause this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The openWindow() method of the Clients interface creates a new top level browsing context and loads a given URL. If the calling script doesn't have permission to show popups, openWindow() will throw an InvalidAccessError.

In Firefox, the method is allowed to show popups only when called as the result of a notification click event.

In Chrome for Android, the method may instead open the URL in an existing browsing context provided by a standalone web app previously added to the user's home screen.

Return value

Examples

// When the user clicks a notification focus the window if it exists or open
// a new one otherwise.
onotificationclick = function(event) {
var found = false;
clients.matchAll().then(function(clients) {
for (i = 0; i < clients.length; i++) {
if (clients[i].url === event.data.url) {
// We already have a window to use, focus it.
found = true;
clients[i].focus();
break;
}
}
if (!found) {
// Create a new window.
clients.openWindow(event.data.url).then(function(windowClient) {
// do something with the windowClient.
});
}
});
};