| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/API/Clients/openWindow | [Back] [Original] |
Get to know MDN better
openWindow(url)
urlURL URL
URL WindowClient null Promise
InvalidAccessError DOMException// OS
if (self.Notification.permission === "granted") {
const notificationObject = {
body: "",
data: { url: `${self.location.origin}/some/path` },
// data: { url: 'http://example.com' },
};
self.registration.showNotification(
"",
notificationObject,
);
}
//
self.addEventListener("notificationclick", (e) => {
//
e.notification.close();
// Window
e.waitUntil(
clients.matchAll({ type: "window" }).then((clientsArr) => {
const windowToFocus = clientsArr.find(
(windowClient) => windowClient.url === e.notification.data.url,
);
if (windowToFocus) {
// URL
windowToFocus.focus();
} else {
// URL
clients
.openWindow(e.notification.data.url)
.then((windowClient) => (windowClient ? windowClient.focus() : null));
}
}),
);
});
| Service Workers Nightly # clients-openwindow |
| Web Proxy Viewer | New URL | Original Page |