FetchEvent: isReload property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("Service Workers API")}}{{Non-standard_header}}{{AvailableInWorkers("service")}}
The **isReload** read-only property of the {{domxref("FetchEvent")}} interface returns true if the event was dispatched by the user attempting to reload the page, and false otherwise. Pressing the refresh button is a reload while clicking a link and pressing the back button is not.
Value
A boolean value.
Examples
js
self.addEventListener("fetch", (event) => {
event.respondWith(async () => {
if (event.isReload) {
// Return something
} else {
// Return something else
}
})();
});Browser compatibility
{{Compat}}
See also
- Using Service Workers
- Service workers basic code example
- Using web workers