ContentIndexEvent: id property

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("Content Index API")}}{{SeeCompatTable}}{{AvailableInWorkers("service")}}

The **id** read-only property of the {{domxref("ContentIndexEvent")}} interface is a {{jsxref('String')}} which identifies the deleted content index via its id.

Value

A {{jsxref("String")}} representation of the deleted content index id.

Examples

This example listens for the {{domxref('ContentIndexEvent', 'contentdelete')}} event and logs the removed content index id.

The {{domxref('ContentIndexEvent')}} is only available to the global scope of a {{domxref('ServiceWorker')}}.

js
self.addEventListener("contentdelete", (event) => {
  console.log(event.id);

  // logs content index id, which can then be used to determine what content to delete from your cache
});

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • An introductory article on the Content Index API
  • Service Worker API, along with information about Cache and CacheStorage