| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/API/Clients/openWindow | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2018 ..
openWindow() Clients URL. , openWindow() InvalidAccessError.
Firefox .
Chrome Android URL- , - (standalone web app), . Chrome Windows.
self.clients.openWindow(url).then(function(windowClient) {
// Do something with your WindowClient
});
Promise, WindowClient, URL- , -, null value .
// OS,
if (self.Notification.permission === "granted") {
const notificationObject = {
body: "Click here to view your messages.",
data: { url: self.location.origin + "/some/path" },
// data: { url: 'http://example.com' },
};
self.registration.showNotification(
"You've got messages!",
notificationObject,
);
}
//
self.addEventListener("notificationclick", (e) => {
//
e.notification.close();
// Windows
e.waitUntil(
clients.matchAll({ type: "window" }).then((clientsArr) => {
// , URL-, , ;
const hadWindowToFocus = clientsArr.some((windowClient) =>
windowClient.url === e.notification.data.url
? (windowClient.focus(), true)
: false,
);
// URL- .
if (!hadWindowToFocus)
clients
.openWindow(e.notification.data.url)
.then((windowClient) => (windowClient ? windowClient.focus() : null));
}),
);
});
| Specification |
|---|
| Service Workers Nightly # clients-openwindow |
This page was last modified on 27 . 2026 . by MDN contributors.
ClientsYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |