ServiceWorkerGlobalScope.oncontentdelete
Draft: This page is not complete.
The oncontentdelete
property of the ServiceWorkerGlobalScope
interface is an event handler fired when an item is removed from the indexed content via the user agent.
Syntax
ServiceWorkerGlobalScope.oncontentdelete = function(event) { ... };
Examples
The following example uses a contentdelete
event handler to remove cached content related to the deleted index item.
self.addEventListener('contentdelete', event => { event.waitUntil( caches.open('cache-name').then(cache => { return Promise.all([ cache.delete(`/icon/${event.id}`), cache.delete(`/content/${event.id}`) ]) }) ); });
Specifications
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
oncontentdelete |
No |
No |
No |
No |
No |
No |
Yes |
Yes |
No |
Yes |
No |
No |
See also
Content Index API
- An introductory article on the Content Index API
- An app which uses the Content Index API to list and remove 'save for later' content
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/oncontentdelete