| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/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 4.
: This feature is only available in Service Workers.
Clients openWindow()
URL .
, openWindow() InvalidAccessError .
Firefox .
openWindow(url)
urlURL . URL .
URL WindowClient ,
null Promise.
InvalidAccessError DOMException// 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();
// Window
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 2025 12 4 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 |