# \[FAQ\] Preventing Window Close & Refresh

**URL:** <https://community.interop.io/t/faq-preventing-window-close-refresh/534>\
**Category:** io.Connect Desktop\
**Tags:** FAQs\
**Created:** [March 25, 2026, 8:55pm UTC](https://community.interop.io/t/faq-preventing-window-close-refresh/534 "2026-03-25T20:55:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![toni.petrov](https://yyz2.discourse-cdn.com/flex028/user_avatar/community.interop.io/toni.petrov/32/17_2.png) [@toni.petrov](https://community.interop.io/u/toni.petrov)\
**Post date:** [March 25, 2026, 8:55pm UTC](https://community.interop.io/t/faq-preventing-window-close-refresh/534/1 "2026-03-25T20:55:53Z")

</div>

**Applies to:** io.Connect Desktop - JavaScript API

* * *

## **Question**

How do I prevent a window from being refreshed (e.g., F5, Ctrl+R)?

## Answer

Use the `onRefreshing` event on the current window and call `prevent()`:

```auto
io.windows.my().onRefreshing((prevent) => {
    prevent();
});

```

* * *

## Question

How do I prevent a window from being closed?

## Answer

Use `onClosing` the same way. Pass `{ showDialog: false }` to suppress the default confirmation dialog:

```auto
io.windows.my().onClosing((prevent) => {
    prevent({ showDialog: false });
});

```

* * *

## Question

Can I also intercept navigation away from the page?

## Answer

Yes. The same `prevent()` pattern is available on three window lifecycle events: `onClosing`, `onRefreshing`, and `onNavigating`.

* * *

## Question

Can I enable these handlers through configuration instead of code?

## Answer

Yes. Close and refresh handlers can be enabled globally or per application in the system configuration via the `closeHandlers` and `refreshHandlers` properties.
